Skip to content

Expose DedicatedWorkerGlobalScope identity in worker realms #108

Description

@wieslawsoltes

Problem

The packaged Code OSS 1.137.0 AppScene audit reaches Monaco worker startup, then logs these events at the same timestamp:

Could not create web worker(s). Falling back to loading web worker code in main thread...
Unhandled promise rejection: Uncaught TypeError: Unable to resolve bare module specifier: module

Evidence is in artifacts/release-ad89179-feature-audit/stderr.log, sequences 34-37.

This is a generic worker-global compatibility gap. Code OSS src/vs/amdX.ts detects a worker with:

typeof self === 'object' && self.constructor &&
  self.constructor.name === 'DedicatedWorkerGlobalScope'

WebScene creates a real isolated worker runtime and assigns self to the global object, but does not install the browser WorkerGlobalScope / DedicatedWorkerGlobalScope identity. Code OSS therefore chooses _nodeJSLoadScript() instead of _workerLoadScript() and runs import('module'). WebScene correctly rejects that bare Node builtin, which masks the primary worker-global identity failure and causes Monaco to report worker startup failure.

Proposed fix

  • Give dedicated-worker globals browser-compatible WorkerGlobalScope and DedicatedWorkerGlobalScope constructor/prototype identity, including self.constructor.name === 'DedicatedWorkerGlobalScope' and self instanceof DedicatedWorkerGlobalScope.
  • Preserve the isolated worker runtime, EventTarget behavior, module loading, and bounded message queues.
  • Add a Code OSS-shaped WPT/regression that makes the same loader selection and proves the worker branch runs.
  • Run the existing worker throughput and queue bounds gates to confirm no performance regression.

Acceptance

  • A module worker reports the expected DedicatedWorkerGlobalScope identity.
  • Code OSS-shaped worker detection selects its dynamic URL import path rather than the Node builtin path.
  • Existing worker/iframe, structured clone, termination, throughput, and capacity tests remain green.
  • Rebuilt packaged Code OSS no longer emits the paired Monaco fallback / bare module diagnostic.

Related to #81, but independently testable as worker-global API identity.

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