Add p-limit to serialize WASM chain access
Summary
Prevent WASM memory corruption from concurrent calls to the shared wax chain instance.
- Add
p-limitdependency to serializegetChain()calls - WASM modules are not thread-safe, and concurrent access from Next.js Server Components causes "memory access out of bounds" errors
Root Cause
The @hiveio/wax library uses a shared singleton accessed concurrently from Server Components. When multiple requests call chain.isValidAccountName() in parallel, they corrupt the shared WASM linear memory.
Solution
Wrap chain access with pLimit(1) to ensure only one WASM operation runs at a time. This is a workaround until wax provides thread-safe guidance.
Test plan
- Deploy and monitor for "memory access out of bounds" errors under load
- Errors should no longer occur after container has been running for extended periods
Related
Edited by gandalf_automation