Skip to content

completeAsyncifyRewind

completeAsyncifyRewind(asyncify): number

Defined in: packages/runtime/src/wasm/tty-bridge.ts:392

Complete an Asyncify rewind cycle by calling handleSleep with a no-op callback.

EmscriptenAsyncify

The Emscripten Asyncify runtime; must currently be in Rewinding state.

number

The return value handed back by handleSleep (the saved async result).

Load-bearing invariant. Asyncify.handleSleep() MUST be called during Asyncify state 2 (Rewinding) to complete the rewind cycle. Omitting this call leaves the WASM stack in an inconsistent state — the next WASM instruction will hit RuntimeError: unreachable and crash the entire WASM instance.

The callback is intentionally empty: the return value comes from the saved Asyncify state, not from the callback. DO NOT remove this function or change its body — the no-op is the contract. If per-site behavior is ever needed, create two named functions instead of mutating this one.

Error if asyncify.state is not Rewinding — indicates the Asyncify guard at the call site was removed.

Related invariant from wasi-asyncify.ts: DO NOT reset the asyncify data buffer between unwind and rewind. The unwound stack data lives in that buffer — clearing it between phases erases the resume context and triggers the same unreachable crash.