Skip to content

fix(fb-marketing-messages): split node-only audience upload out of the router graph - #1569

Merged
viethung0o0 merged 1 commit into
mainfrom
fix/edge-safe-marketing-imports
Oct 27, 2026
Merged

viethung0o0 merged 1 commit into
mainfrom
fix/edge-safe-marketing-imports

Conversation

@viethung0o0

@viethung0o0 viethung0o0 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the Edge Runtime warnings caused by #1550 (fb-marketing-messages).

Cause: in #1550 the audience service used by the builder's router also imported the file parsing and hashing code (node:stream, node:crypto). The router is traced into the Edge instrumentation bundle, so the builder logged "A Node.js module is loaded … not supported in the Edge Runtime".

Fix: move the upload part (create / uploadMore, file parsing, hashing) into its own module, @chatbotx.io/business/facebook-marketing-message-audience/upload, used only by the server actions and the public API. The statistics cache key now uses the shared sha256Hex. A new test fails if Node-only code reaches the router again, and AGENTS.md invariant 25 documents the rule.

…e router graph

The audience service added in #1550 mixed the read path (list, live status,
delete) with file parsing and row hashing (node:stream, node:crypto). The
builder's oRPC router imports the read path, and Next.js traces that router
into the Edge instrumentation bundle, so the Node imports surfaced as
"A Node.js module is loaded ... not supported in the Edge Runtime".

- Move create/uploadMore and the parse + hash step into
  facebook-marketing-message-audience/upload.service.ts, exported only through
  the new `/upload` subpath and used by the server actions and public API
- The statistics cache key hashes with the shared Web Crypto sha256Hex, since
  that read runs inside the router
- Add a builder test that walks the edge instrumentation graph and fails on
  any Node built-in or process API the Edge runtime lacks
- Document the split rule as AGENTS.md invariant 25 and in CLAUDE.md
@github-actions github-actions Bot added the bug Something isn't working as expected label Oct 27, 2026
@viethung0o0
viethung0o0 merged commit acc9fff into main Oct 27, 2026
6 checks passed
hello-jackytruong referenced this pull request in hello-jackytruong/ChatWorkAI Nov 22, 2026
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