Skip to content

Extension sandbox can hang 'Loading instances...' when a second IPC message hits a busy goja VM #33

Open

Description

@wayback09

Symptom

In the mod browsers (Modrinth, CurseForge, Mod Manager), the install modal can get stuck on Loading instances... forever. #32 fixed the switching-browsers variant (stale EventsOn subscription). This issue covers the remaining hang.

Root cause

  • Manager.HandleIPCMessage (pkg/extensions/manager.go:375) invokes the extension's onMessage callback on the goja VM without any synchronization. goja is single-threaded and not thread-safe.
  • Sandbox callbacks block the VM for long Go operations:
    • installMod runs the entire mod download synchronously inside the VM call (manager.go:147-195).
    • requestConfirmation blocks the VM for up to 2 minutes waiting on the 'Allow extension action?' dialog (manager.go:283-304).
  • If a second IPC message arrives for the same extension while the first is in flight (e.g. opening another mod's modal while a confirm dialog or download is active), the second call enters the busy VM concurrently → goja hangs/corrupts → the callback never returns → no response event is emitted → the iframe waits forever.

Contributing issue

The iframe bridge sendMessage() in both modrinth and curseforge ui/script.js has no timeout and only resolves when a matching requestId arrives. Any lost/dropped response leaves the modal permanently stuck with no error or retry path.

Suggested fixes

  1. Serialize sandbox callback execution with a per-sandbox mutex (second message waits for the first, then completes normally).
  2. Add panic recovery in HandleIPCMessage that always emits an error response back to the iframe instead of silently dropping it.
  3. Long operations (downloads, confirmation dialogs) should not hold the goja VM.
  4. Add a timeout (e.g. 15s) to sendMessage in the extension UIs and surface a 'timed out, retry' state instead of an infinite spinner.

Related: #32 (fixed switching-browsers hang)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions