Skip to content

Commit 98a3984

Browse files
test(contracts): cover the unstringifiable payload with a bigint, not stack depth
How deep a payload must be before JSON.stringify throws depends on the engine and thread, so the deep row passed only on some runtimes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent cefe23c commit 98a3984

2 files changed

Lines changed: 3 additions & 8 deletions

File tree

‎packages/contracts/src/composerContext.test.ts‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,8 @@ describe("OrchestrationMessageContext", () => {
223223
payload: { count: Number.NaN },
224224
},
225225
{ ...knownRecords["review-comment"], contextId: "ctx_3", fenceLanguage: undefined },
226-
{
227-
...base,
228-
contextId: "ctx_4",
229-
kind: "future-kind",
230-
label: "deep",
231-
payload: Array.from({ length: 20_000 }).reduce((inner: unknown) => [inner], 0),
232-
},
226+
// JSON.stringify throws on a bigint on every engine.
227+
{ ...base, contextId: "ctx_4", kind: "future-kind", label: "y", payload: { n: 1n } },
233228
],
234229
});
235230
expect(decodeContext(wire).records.map((record) => record.contextId)).toEqual(["ctx_1"]);

‎packages/contracts/src/composerContext.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ export const UnknownContextRecord = Schema.Struct({
250250
try {
251251
encoded = JSON.stringify(payload);
252252
} catch {
253-
// Cycles, bigints and payloads nested too deep to stringify.
253+
// Cycles, bigints, and payloads nested deeper than this engine's stack.
254254
return false;
255255
}
256256
// Only JSON values, so a payload the wire cannot carry (a Date, NaN, an

0 commit comments

Comments
 (0)