You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bb-async-job: the local handler receives the caller's payload object itself, on AWS it receives a JSON copy (mutations, Date, Map, Set, Buffer and class instances differ) #1276
I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
Which package(s) are affected?
Building Block: async-job, Building Block: cron-job
Describe the bug
On AWS, submit(payload) sends JSON.stringify(payload) to SQS and the handler gets JSON.parse() of it. The local mock measures the JSON size but then queues the original object and passes it to the handler on the next tick. So the handler sees whatever the caller does to the object after submit() resolves, and every value JSON can't represent arrives intact:
Payload field
Handler sees locally
Handler sees on AWS
a field the caller changes right after await submit(payload)
A handler written as payload.createdAt.getTime() or payload.ids.has(x) works in npm run dev and throws on AWS. CronJob has the same pattern for its input: a Date in input reaches the local handler as a Date and the deployed one as a string.
Expected behavior
The mock passes the handler JSON.parse(JSON.stringify(payload)) (it already computes the string for the size check), taken at submit() time, for submit(), submitBatch() and CronJob's input. The README can then state that payloads are JSON-serialized in both environments.
Likely location: submit() in packages/bb-async-job/src/index.mock.ts (lines 199–232 queue payload as-is; the serialized string from validatePayload() around line 286 is discarded) versus packages/bb-async-job/src/index.aws.ts (around line 433, JSON.stringify(payload)); CronJob keeps options.input in packages/bb-cron-job/src/index.mock.ts (lines 71 and 134).
Activity