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
Copy file name to clipboardExpand all lines: rivetkit-typescript/CLAUDE.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -145,7 +145,8 @@ Cloudflare Workers forbid `setTimeout`, `fetch`, `connect`, and other async I/O
145
145
- Run `pnpm --filter @rivetkit/rivetkit-wasm run check:package` after wasm package export or files changes to verify the published tarball includes the root entrypoint and wasm artifacts.
146
146
- Build `@rivetkit/rivetkit-wasm` with its package-local pinned `wasm-pack` dependency. Do not use `npx -y wasm-pack`.
147
147
- Intern wasm bridged `RivetErrorSchema` values by `(group, code)` only; live per-error messages must stay on `RivetError.message` instead of expanding the schema cache key.
148
-
- Track wasm websocket callback regions in a map keyed by monotonic region IDs and remove entries on end so repeated callbacks do not retain empty slots.
148
+
- Track wasm websocket callback regions in a map keyed by active region IDs and remove entries on end so repeated callbacks do not retain empty slots.
149
+
- Treat wasm websocket callback region ID `0` as the untracked sentinel; wrap `u32` allocation by skipping live IDs instead of panicking.
Copy file name to clipboardExpand all lines: scripts/ralph/prd.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -212,8 +212,8 @@
212
212
"Tests pass"
213
213
],
214
214
"priority": 13,
215
-
"passes": false,
216
-
"notes": ""
215
+
"passes": true,
216
+
"notes": "Wasm websocket callback region IDs now wrap across the u32 boundary, skip ID 0, and skip live region IDs instead of panicking. Added wasm-target regression coverage for wraparound with live regions."
Copy file name to clipboardExpand all lines: scripts/ralph/progress.txt
+11-1Lines changed: 11 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,8 @@
17
17
- `@rivetkit/rivetkit-wasm` builds must use the package-local pinned `wasm-pack` dependency; do not shell through `npx -y wasm-pack`.
18
18
- Runtime parity tests can instantiate `NapiCoreRuntime` and `WasmCoreRuntime` with fake binding classes, then drive shared actor glue through `buildNativeFactory(...)` without requiring generated NAPI or wasm artifacts.
19
19
- NAPI actor-event synthetic `RivetErrorSchema` values should be `static` when fields are compile-time constants, or process-interned by `(group, code)` with `scc::HashMap` when the default message is dynamic.
20
-
- Wasm websocket callback regions should be tracked in a map keyed by monotonic region IDs and removed on end so callback churn does not retain empty slots.
20
+
- Wasm websocket callback regions should be tracked in a map keyed by active region IDs and removed on end so callback churn does not retain empty slots.
21
+
- Wasm websocket callback region ID `0` is the untracked sentinel; `u32` allocation wraps by skipping live IDs instead of panicking.
21
22
- NAPI `Ref::unref` needs an `Env`; cleanup from worker or `Drop` paths should be routed through an Env-bearing TSF and must tolerate addon shutdown by falling back to a bounded leak.
22
23
- Core `ActorContext::register_task(...)` must race registered runtime promises against `shutdown_deadline_token()` so shutdown drain cannot hang forever.
23
24
@@ -144,3 +145,12 @@ Started: Sat May 2 02:13:32 AM PDT 2026
144
145
- Keep native and wasm `register_task(...)` behavior in a shared helper where possible so the two cfg-specific public signatures cannot diverge.
145
146
- The package-wide core test suite currently has an unrelated hanging inspector debounce test, so use focused tests plus `check-rivetkit-core-wasm.sh` for this shutdown path.
146
147
---
148
+
## 2026-05-02 03:33:22 PDT - US-013
149
+
- Implemented wraparound allocation for wasm websocket callback region IDs, skipping ID `0` and any IDs still live in the active region map instead of panicking at `u32::MAX`.
150
+
- Added a wasm-target regression test that seeds the allocator near `u32::MAX`, keeps a low ID live, and verifies wraparound does not collide.
- Checks: `cargo test -p rivetkit-wasm --target wasm32-unknown-unknown --no-run websocket_callback_region_ids_wrap_without_collision`, `pnpm --filter @rivetkit/rivetkit-wasm run check:wasm`, `pnpm --filter @rivetkit/rivetkit-wasm run check-types`, `pnpm --filter @rivetkit/rivetkit-wasm run check:package`.
153
+
- **Learnings for future iterations:**
154
+
- Wasm websocket callback region allocation preserves the existing `u32` JS surface and uses `0` as the untracked sentinel for the impossible exhausted-ID case.
155
+
- Tests that assert wraparound should keep an existing low region ID live so the allocator proves it skips active IDs after wrapping.
0 commit comments