developit / developit/workerize-loader

Error when initializing Child Workers

Đang mở
#99 2 bình luận 2 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
2.3k
Fork
85
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.