fix(sequence): compute dispatch bucket without node crypto - #1141
Merged
Conversation
`dispatch-manager` picked a bucket with Node's `crypto.createHash`, so any edge-reachable importer of `@chatbotx.io/business` (sequence service → contact-schedule) dragged `crypto` into the Edge Runtime and broke the builder's instrumentation compile (introduced by #1102). Replace it with a pure-JS string hash. The bucket is only a load-distribution key, computed once and persisted on the row (never recomputed), so even 0–255 spread is all that matters.
Locks the pure-JS bucketing against a distribution regression (e.g. a weak hash leaving half the buckets empty), since workers scan every bucket.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since #1102,
sequence/serviceimportscontact-schedule→dispatch-manager, which picked a dispatch bucket with Node'scrypto.createHash. That pullscryptointo the builder's Edge Runtime instrumentation (theorpc.servergraph), so the Edge compile fails withnode-module-in-edge-runtime.Fix
Replace
cryptoincalculateBucketwith a pure-JS polynomial string hash (no Node built-in, no bitwise). The bucket is only a load-distribution key: computed once and persisted on the dispatch row, never recomputed (cancel/scan read it back). So the only requirement is an even 0–255 spread — verified full 256-bucket coverage.Test
pnpm --filter @chatbotx.io/sequence-scheduler test— 104 passingsequence-scheduler+business