Skip to content

Wait for WASM runtime before running function-search worker#12

Open
VA00 wants to merge 1 commit into
mainfrom
codex/add-file-dialog-for-function-discovery
Open

Wait for WASM runtime before running function-search worker#12
VA00 wants to merge 1 commit into
mainfrom
codex/add-file-dialog-for-function-discovery

Conversation

@VA00
Copy link
Copy Markdown
Owner

@VA00 VA00 commented Jan 6, 2026

Motivation

  • Prevent a crash where the worker calls into WASM before Emscripten runtime helpers (e.g. _emscripten_stack_get_current) are available.
  • Ensure function-search messages received early are not lost and do not trigger invalid ccall usage.
  • Make the worker robust to messages arriving before vsearch.js has finished initializing.

Description

  • Update calculator_frontend/public/wasm/worker_function.js to add a runtimeReady flag and a pendingMessages queue.
  • Add Module.onRuntimeInitialized handler that sets runtimeReady, posts a ready message, and flushes queued messages by calling handleWork.
  • Refactor the worker entry to use handleWork for processing work and wrap the original onmessage to queue messages until runtime readiness.

Testing

  • No automated tests were run for this change.
  • Runtime behavior was adjusted so the worker waits for Module.onRuntimeInitialized before invoking WASM entrypoints, eliminating the previously observed _emscripten_stack_get_current error in prior runs.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant