Skip to content

Regression: mainScriptUrlOrBlob ignored when USE_ES6_IMPORT_META is off #23769

Closed

Description

@JoeOsborn

Per #23171 (comment)

The recent removal of USE_ES6_IMPORT_META broke a use case like this:

  1. I want to host an emscripten-compiled package somewhere (e.g., a CDN) that is compiled to use pthreads
  2. I want to instantiate a module from those scripts on another origin domain
  3. Browsers refuse to download cross-origin workers, so I can't create threads.

This used to be supported using either an importScripts() hack in the worker or by downloading the whole script as a blob, but now that's not possible since the fix in #23171 forces the use of a specific file name.

Activity

  1. JoeOsborn commented on Feb 26, 2025

    @JoeOsborn
    ContributorAuthor

    For a bit more detail: Using a blob as the actual script means that import.meta.url is a blob, so new URL(...) can't work. Using a mainScriptBlobOrUrl is just ignored. So both of the tricks I've used in the past for cross origin workers are not available.

  2. sbc100 commented on Feb 26, 2025

    @sbc100
    Collaborator

    Thanks Joe! We are obviously lacking some test coverage here.

  3. JoeOsborn commented on Feb 27, 2025

    @JoeOsborn
    ContributorAuthor

    I think a reasonable fix for this is to:

    1. If mainScriptUrlOrBlob is set, create the worker as in the old non-use-import-meta case (or else deprecate that field under export_es6 and assert that mainScriptUrlOrBlob is not set)
    2. If import.meta.url is a blob url, use it instead of creating a new URL.
  4. sbc100 commented on Mar 20, 2025

    @sbc100
    Collaborator

    I believe this was fixed in #23890 and can be closed?

  5. JoeOsborn commented on Mar 20, 2025

    @JoeOsborn
    ContributorAuthor

    Fixed in #23890

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