andywer / andywer/threads.js

create worker with *.ts when master in ts-node environment cause error

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

Mô tả

`spawn(new Worker('worker.ts'))` will cause error when the script is executed in **ts-node environment**. As follow:

```
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ({
diagnosticText: 'app/util/worker.ts(8,2): error TS2695: Left side of comma operator is unused and has no side effects.\r\n',
diagnosticCodes: [ 2695 ]
})

```
I think it's because ts-node is registed multiple times, as thread.js register ts-node in https://github.com/andywer/threads.js/blob/master/src/master/implementation.node.ts#L55. Then error occurred:
https://github.com/TypeStrong/ts-node/issues/1690
https://github.com/TypeStrong/ts-node/issues/409

A simple way to fix this may be adding option to skip re-register, or detecting ts-node env by symbol it expose, like this: `if (process[Symbol.for("ts-node.register.instance")])`

Hope to check again if these are corrected. If necessary, I can provide a PR to fix this. Thanks a lot.

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.