Skip to content

fix(sandbox): Worker→Host message routing broken — storage hangs and events silently dropped #1990

@TCP404

Description

@TCP404

Problem

The extension sandbox (SandboxHostsandboxWorker) has two message routing bugs that make the Worker→Host communication channel non-functional:

Bug 1: aion.storage API calls hang indefinitely

When a sandboxed extension calls aion.storage.get/set/delete, the Worker sends an api-call message to the Host. But SandboxHost.handleMessage() has no case 'api-call' — the message falls through to default: break and is silently dropped. The Worker's pendingMainCalls Promise never resolves or rejects, causing the extension code to hang forever.

Root cause: sandbox.ts:218-247handleMessage() only handles api-response, log, and event, not api-call.

Bug 2: Extension events and UI messages silently dropped

When a sandboxed extension calls aion.emitEvent() or aion.postToUI(), the Worker sends an event message. But the Host's case 'event' is an empty break — events are never forwarded to extensionEventBus or the renderer process.

Root cause: sandbox.ts:241-243 — comment says "handled by event bus" but no code exists.

Additional issue: No timeout on Worker→Host calls

callMainThread() in sandboxWorker.ts creates Promises without timeouts. Combined with Bug 1, this means any aion.storage.* call will hang forever with no error.

Summary

Direction Message type Status
Host → Worker api-call Works
Host → Worker event Works
Worker → Host api-call (storage) Hangs forever
Worker → Host event (emitEvent/postToUI) Silently dropped
Worker → Host log, ready Works

Fix

  • Add case 'api-call' to handleMessage() with generic apiHandlers routing
  • Forward event messages: ext:*extensionEventBus, ui-messageonUIMessage callback
  • Add 30s timeout to callMainThread()
  • Create ExtensionStorage as backing KV store for aion.storage API

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