fix(rivetkit-wasm): fix mem leaks#4880
Conversation
Code Review: fix(rivetkit-wasm): fix mem leaks (#4880)This is a solid, focused PR. The work falls into four categories: fixing Box::leak memory leaks by interning schemas globally, centralizing HTTP status promotion in rivetkit-core, fixing the wasm websocket callback region slot management, and wiring register_task correctly. The test coverage is unusually good. A few issues and one genuine bug are noted below. Bug: Duplicate import in napi_actor_events.rs test fileFile: The same Bug/Logic: anyhow_to_bridge_rivet_error_payload - the should_promote condition may incorrectly override a deliberately-set errorFiles: The guard uses an context.public_ != Some(true) && context.status_code.map_or(true, |s| s == 500)Duplication: should_promote logic and payload serialization between NAPI and wasmThe Missing tracing log in wasm anyhow_to_bridge_rivet_error_payloadThe NAPI version emits a Off-by-one in allocate_websocket_callback_region_idThe loop Overly strict monotonic assertion in testThe inline test Global schema-count assertion is racey under parallel testsThe inline test Missing trailing newline in error artifact
Positive observations
|
Preview packages published to npmInstall with: npm install rivetkit@pr-4880All packages published as Engine binary is shipped via Docker images: docker pull rivetdev/engine:slim-34d3f72
docker pull rivetdev/engine:full-34d3f72Individual packagesnpm install rivetkit@pr-4880
npm install @rivetkit/react@pr-4880
npm install @rivetkit/rivetkit-napi@pr-4880
npm install @rivetkit/workflow-engine@pr-4880 |
b8a3dc6 to
466c831
Compare
7600ef8 to
ecba65a
Compare
466c831 to
f914045
Compare
PR Review: fix(rivetkit-wasm): fix mem leaksStatus: DRAFT OverviewThis PR addresses memory leaks and correctness gaps in the wasm runtime identified in a review of #4860:
Bugs / Potential Compile Errors1. Duplicate import in The file already contains 2. NAPI The cache is declared with key type The wasm-side counterpart ( Logic Concerns
In both Misleading monotonicity assertion in wasm websocket test
Missing Method ReferenceThe Dependency Concerns
These are build-only dev dependencies so user impact is nil, but worth checking whether a newer wasm-pack version clears them. What is Done Well
|
f914045 to
8bac2e2
Compare

Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: