Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/hardened-serialization-simplify.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@workflow/core': patch
'workflow': patch
---

Simplify hardened serialization: intrinsic captures assert at import instead of degrading per use, `URLSearchParams` now serializes natively on Node 18, and bound-function getters are reported as guest code (previously a getter defined via `fn.bind()` executed with an empty report).
20 changes: 20 additions & 0 deletions packages/core/src/serialization/hardened.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,26 @@ describe('hardened serialization: unavoidable guest code is recorded', () => {
expect(stats.executions).toEqual([{ kind: 'getter', detail: 'computed' }]);
});

it('records a bound-function getter (native-looking, but runs guest code)', () => {
// `fn.bind()` stringifies as `function bound fn() { [native code] }`, so
// a nativeness check alone would cache it as engine-provided and let
// workflow code launder a side-effectful getter past the report.
const vm = makeVm();
const value = vm.evaluate(`(() => {
globalThis.boundRuns = 0;
const spy = function () { globalThis.boundRuns++; return 'laundered'; };
const o = {};
Object.defineProperty(o, 'x', { enumerable: true, get: spy.bind(null) });
return o;
})()`);

const { wire, stats } = vm.serialize(value);

expect(wire).toContain('laundered');
expect(vm.evaluate('globalThis.boundRuns')).toBe(1);
expect(stats.executions).toEqual([{ kind: 'getter', detail: 'x' }]);
});

it('still identifies a proxied host class, and reports the traps', async () => {
// Next.js hands the runtime a proxied `NextRequest`. `instanceof`
// forwards through the `getPrototypeOf` trap, and the Request reducer
Expand Down
Loading
Loading