Skip to content

Blob URL does not work on Node.js #30

Description

@sindresorhus

The readme says:

Worker() accepts a module URL, Blob URL or Data URL

But running the following on Node.js 18 results in a crash:

import Worker from 'web-worker';

const blob = new Blob(['foo'], {type: 'text/javascript'});
const url = URL.createObjectURL(blob);
const worker = new Worker(url, {type: 'module'});
node:internal/errors:466
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_URL_SCHEME]: The URL must be of scheme file
    at new NodeError (node:internal/errors:377:5)
    at Object.fileURLToPath (node:internal/url:1484:11)
    at new Worker (/Users/sindresorhus/dev/oss/make-asynchronous/node_modules/web-worker/cjs/node.js:108:19)
    at file:///Users/sindresorhus/dev/oss/make-asynchronous/x.js:5:16
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:409:24)
    at async loadESM (node:internal/process/esm_loader:85:5)
    at async handleMainPromise (node:internal/modules/run_main:61:12) {
  code: 'ERR_INVALID_URL_SCHEME'
}

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions