developit / developit/workerize-loader

Error when initializing Child Workers

未關閉
#99 2 則留言 2 個 reaction 已指派 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 程式碼開始,追蹤 child worker 如何從 parent 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 摘要。