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

Worker Threads Crash #2250

Closed
devwoojin opened this issue May 24, 2021 · 2 comments
Closed

Worker Threads Crash #2250

devwoojin opened this issue May 24, 2021 · 2 comments

Comments

@devwoojin
Copy link

Summary of Problem

(Please answer all 3)

  • What are you trying to do?
    I want to open a serial connection from within a WorkerThread.

  • What happens?
    I get this Error:

FATAL ERROR: HandleScope::HandleScope Entering the V8 API without proper locking in place
1: 00007FF7B80B058F napi_wrap+109311
2: 00007FF7B80552B6 v8::internal::OrderedHashTablev8::internal::OrderedHashSet,1::NumberOfElementsOffset+33302
3: 00007FF7B8056086 node::OnFatalError+294
4: 00007FF7B891305B v8::HandleScope::Initialize+107
5: 00007FF7B88F8E8E v8::HandleScope::HandleScope+14
6: 00007FF7B80D3D8D node::CallbackScope::CallbackScope+429
7: 00007FF7B80D43E6 node::CallbackScope::~CallbackScope+1126
8: 00007FF7B80D4A61 node::MakeCallback+209
9: 00007FFE8FF1B2F6

  • What should have happened?
    SerialPort should work as normal.

Code to Reproduce the Issue

main.js

const { Worker, isMainThread } = require('worker_threads');

const worker = new Worker('./worker.js');
console.log('isMainThread:', isMainThread); // true

worker.on('message', (msg) => {
  console.log(msg);
});

// Code

worker.js

const { Worker, isMainThread, parentPort, workerData } = require('worker_threads');
const SerialPort = require('serialport');

console.log("Serial Worker");

const port = new SerialPort("COM3", {baudRate: 115200}, function (err) {
  if (err) {
    console.log('Error: ', err.message)
    return;      
  }
});

port.on('data', function (data) {
  console.log('Data:', data)
})
  
// Code

Versions, Operating System and Hardware

  • SerialPort@?
    serialport": "^9.0.7",
  • Node.js v?
    v14.15.5
  • Windows? Linux? Mac?
    windows 10
  • Hardware and chipset? (Prolific/FTDI/Other)
    FTDI
@reconbot
Copy link
Member

We don't support workers at this time #1938

@ScreamZ
Copy link

ScreamZ commented Nov 15, 2023

@reconbot Any recommendations on high-consuming serial communication (just like DMX) ? to avoid blocking the loop. Currently, I'm using https://github.com/moritzruth/node-enttec-open-dmx-usb/tree/main and it plays with micro sleep. Which could be nice to be used in another thread ?

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

No branches or pull requests

3 participants