Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
windschaser opened this issue Dec 2, 2022 · 0 comments

Comments

@windschaser
Copy link

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:
TypeStrong/ts-node#1690
TypeStrong/ts-node#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant