You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I searched existing issues before opening this one to avoid duplicates
I'm able to reproduce this issue and prove it with a minimal reproduction
I understand this is not a place to ask for free debugging support
Problem
I think the problem is similar to this #382. But I found different case. I create minimal reproduce below. It's just simple scheduler using breejs. When I run tsx index.ts it will run the scheduler every 10 second just to console.log. Then this error is occured
Worker for job "hello script" had an error {
err: ReferenceError [Error]: ___tsxInteropDynamicImport is not defined
at [worker eval]:1:71
at [worker eval]:1:126
at Script.runInThisContext (node:vm:123:12)
at Object.runInThisContext (node:vm:299:38)
at node:internal/process/execution:82:21
at [worker eval]-wrapper:6:24
at runScript (node:internal/process/execution:81:62)
at evalScript (node:internal/process/execution:103:10)
at MessagePort.<anonymous> (node:internal/main/worker_thread:152:7)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:757:20)
}
This error doesn't occure on tsx v3, and I can confirm that if you run the script without node:worker_threads, everything is work fine
// change this
const { workerData } = await import("node:worker_threads");
// to this
const workerData = {};
Expected behavior
Script run and scheduler will print the workerData in the console every 10 seconds
In this case, basically an eval is happening so it can't reach the closure reference. The same reason you had to dynamically import worker_threads inside path instead of at the top of the file. This issue is closer to #113.
Precheck
Problem
I think the problem is similar to this #382. But I found different case. I create minimal reproduce below. It's just simple scheduler using breejs. When I run tsx index.ts it will run the scheduler every 10 second just to console.log. Then this error is occured
This error doesn't occure on tsx v3, and I can confirm that if you run the script without node:worker_threads, everything is work fine
Expected behavior
Script run and scheduler will print the workerData in the console every 10 seconds
Minimal reproduction URL
https://github.com/axmad386/repro-tsx
Version
v4.1.1
Node.js version
v18.18.2
Package manager
pnpm
Operating system
Linux
Contributions
The text was updated successfully, but these errors were encountered: