developit / developit/workerize-loader

Error when initializing Child Workers

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

説明

I tried initializing child web workers from a parent worker, and it seems to work well with the exception of the following error being thrown:

```
rpc-wrapper.js:20 Uncaught ReferenceError: document is not defined
at Worker. (rpc-wrapper.js:20)
```

Digging in, it seems like its part of building up the `ready` event, although document is not in scope in the context of a WebWorker.

```
let evt = document.createEvent('Event');
evt.initEvent(d.method, false, false);
evt.data = d.params;
worker.dispatchEvent(evt);
```

What is the purpose of the `ready` event? Is there a way to build the event in a WebWorker-safe manner? I've looked into `new Event`, but that's not IE compatible.

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

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

rpc-wrapper.js の 20 行目付近にある ready-event のコードから始め、parent worker から child worker がどのように初期化されるかを追跡してください。その経路で document にアクセスしている理由と、ready event がどのように動作する想定なのかを確認してください。child worker が document エラーなしで初期化され、ready event とその IE 互換性が維持されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, webpack
領域
tooling, web-dev
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

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

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