deno
f82cc27a - fix(core): handle async op promise id wraparound (#35126)

Commit
160 days ago
fix(core): handle async op promise id wraparound (#35126) The async op promise id is incremented with `(id + 1) & 0xffffffff`, which coerces to a signed int32 in JS, so after 2^31 dispatched ops the counter goes negative. From that point the `promiseId < nextPromiseId - RING_SIZE` check in `__resolvePromise()` misfires for ops that started before the wraparound and were evicted from the promise ring to the overflow map while still pending: the lookup goes to the ring instead of the map and the process crashes with "Missing promise in ring @ <id>" (or could resolve a wrong promise). This is what killed long-running servers after billions of ops. The new regression test reproduces that exact error against the old code. The counter now wraps back to 0 instead of going negative (promise ids must stay non-negative i32s for the Rust side), and each ring entry stores its own promise id, so ring-vs-map membership is decided by an identity check instead of arithmetic on the global counter, which is wraparound safe. Fixes #22759
Author
Parents
Loading