We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
12+
v20
No response
64
`
// 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;
const portOptions: SerialPortOpenOptions<any> = { path: 'COM4', baudRate: 921600, dataBits: 8, parity: 'none', stopBits: 1, autoOpen: false, }; // if (!port) { let port = new SerialPort(portOptions , () => { console.log('serial port opened'); }); // } port.open(() => { port.on("data", (data: Buffer) => { console.log(data.toString()); }); }); parentPort.postMessage({ type: 'SERIAL_PORT_STARTED' }); }
}); }
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
when i use it in mainthread, it works. but i really need to use it in worker thread....
aaaa
The text was updated successfully, but these errors were encountered:
Looks related to #1938.
Sorry, something went wrong.
No branches or pull requests
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: