developit / developit/web-worker

Blob URL does not work on Node.js

オープン
#30 コメント 3 件 リアクション 9 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
1.2k
フォーク
57
PR マージ指標
30日以内にマージされた PR はありません

説明

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:

```js
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'
}
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。