WASM memory corruption from concurrent isValidAccountName() calls in Server Components

Problem

Server-side rendering throws intermittent WASM memory errors:

  WaxError: Non-typed Error during Wasm call: RuntimeError: memory access out of bounds
      at nn.isValidAccountName
      at /app/apps/blog/.next/server/app/[param]/[p2]/[permlink]/page.js

The error occurs under load and resolves after container restart.

Root Cause

The @hiveio/wax library uses a shared singleton (HiveChainService.hiveChain) accessed concurrently from Next.js Server Components. WASM modules are not thread-safe - concurrent calls to methods like chain.isValidAccountName() corrupt the shared linear memory.

Affected code path:

  • apps/blog/utils/validate-links.tsisUsernameValid()
  • packages/transaction/lib/chain.tsgetChain() (singleton)
  • packages/transaction/lib/hive-chain-service.ts → shared static instance

Concurrent call sites:

  • apps/blog/app/[param]/[p2]/route.ts
  • apps/blog/app/[param]/[p2]/[permlink]/page.tsx
  • Layout components validating usernames

Proposed Fix

Add concurrency control (mutex/semaphore) around WASM-dependent chain calls to serialize access. Investigating with wax team for recommended approach.