1.3 KiB
1.3 KiB
WRNexusJS v0.6.0 R10 peer-function state fix
Failure
The compiler test browser codegen binds peer client functions through the scoped function table failed because an outer client function captured local state before calling a peer function. The peer updated context.state, but the outer function's finally block copied its stale local value back over the peer update.
Fix
packages/compiler/src/client-codegen.ts now generates peer-function wrappers that:
- synchronize the caller's local state into
context.statebefore the peer call; - invoke the peer through
context.functions; - refresh local aliases from
context.stateafter synchronous completion, asynchronous completion, or a synchronous throw; - copy local state back only when it actually changed from the function-entry snapshot.
This preserves shared scoped state for nested client/shared function calls without changing synchronous functions into promises.
Regression validation
- Exact peer-call execution probe: passed (
run()callsincrement(), final state is1). - Focused TypeScript compiler check: passed.
- UI browser targets generated and syntax-checked: 108/108.
- UI and showcase WRN files parsed: 250/250.
- VS Code tests: 28/28.
- Root v0.6 validator: 18 passed, 0 failed (Bun availability warning only in the packaging environment).