Skip to content

fix(sequence): compute dispatch bucket without node crypto - #1141

Merged
viethung0o0 merged 2 commits into
mainfrom
fix/sequence-bucket-no-crypto
Sep 10, 2026
Merged

fix(sequence): compute dispatch bucket without node crypto#1141
viethung0o0 merged 2 commits into
mainfrom
fix/sequence-bucket-no-crypto

Conversation

@viethung0o0

Copy link
Copy Markdown
Contributor

Problem

Since #1102, sequence/service imports contact-scheduledispatch-manager, which picked a dispatch bucket with Node's crypto.createHash. That pulls crypto into the builder's Edge Runtime instrumentation (the orpc.server graph), so the Edge compile fails with node-module-in-edge-runtime.

Fix

Replace crypto in calculateBucket with 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 passing
  • typecheck: sequence-scheduler + business
  • lint clean

`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.
@github-actions github-actions Bot added the bug Something isn't working as expected label Sep 10, 2026
Locks the pure-JS bucketing against a distribution regression (e.g. a weak hash leaving half the buckets empty), since workers scan every bucket.
@viethung0o0
viethung0o0 merged commit a67fdc1 into main Sep 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants