-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Cannot work in a worker thread... please save me #2748
Comments
Looks related to #1938. |
The very same happens for me with SerialPort v12 and Node v20 in x64 (WSL) or inside Docker on arm64 platform.
My code is pretty much the same as the example above. Is there any way to get this working? |
Yeah, having the same issue. I'm trying to integrate serialport in my iot nuxt app. But nuxt is using workers so getting the same error |
@egidiusmengelberg did you get any success? Trying to do exactly the same. |
I developed by constantly building the application and running it afterwards. Running the production build does not use workers which means serialport is working fine. |
Thank you, seems like it's on the nitro roadmap, as mentioned here. |
SerialPort Version
12+
Node Version
v20
Electron Version
No response
Platform
No response
Architecture
64
Hardware or chipset of serialport
No response
What steps will reproduce the bug?
`
// main.ts
import { Worker } from 'worker_threads';
if (require.main === module) {
const worker = new Worker('./dist/serialWorker.js');
worker.on('message', (message) => {
console.log('Received message from worker:', message);
});
worker.postMessage({ type: 'START_SERIAL_PORT', port: '/dev/ttyUSB0', baudRate: 9600 });
}`
`// serialWorker.ts
import { parentPort } from 'worker_threads';
import { SerialPort, SerialPortOpenOptions } from 'serialport';
if (parentPort) {
parentPort.on('message', (message) => {
if (message.type === 'START_SERIAL_PORT') {
// const { port, baudRate } = message;
});
}
`
What happens?
when i use seriaport in worker thread, it error:
D:\codes\desktop-mmb>node dist/index.js Received message from worker: { type: 'SERIAL_PORT_STARTED' } FATAL ERROR: HandleScope::HandleScope Entering the V8 API without proper locking in place 1: 00007FF6A8D7436F node::SetCppgcReference+15695 2: 00007FF6A8CEC686 EVP_MD_meth_get_input_blocksize+76102 3: 00007FF6A8CEE57C node::OnFatalError+252 4: 00007FF6A974F549 v8::HandleScope::Initialize+137 5: 00007FF6A97376FE v8::HandleScope::HandleScope+14 6: 00007FF6A8D3FD8A napi_open_handle_scope+154 7: 00007FFE7CD0AFEA 8: 00007FF6A8DD8A6B uv_update_time+491 9: 00007FF6A8DD85E4 uv_run+900 10: 00007FF6A8DA94D2 node::SpinEventLoop+402 11: 00007FF6A8C9CAB3 DH_get0_priv_key+151875 12: 00007FF6A8D2E925 node::Start+3989 13: 00007FF6A8D2D9C0 node::Start+48 14: 00007FF6A8B0D76C AES_cbc_encrypt+150940 15: 00007FF6A9F3BCDC inflateValidate+17308 16: 00007FFE9AF2257D BaseThreadInitThunk+29 17: 00007FFE9B7CAA58 RtlUserThreadStart+40
What should have happened?
when i use it in mainthread, it works.
but i really need to use it in worker thread....
Additional information
aaaa
The text was updated successfully, but these errors were encountered: