Issue with `serialport` in dev
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 899
- Avg merge
- 2d 24m
- Merged PRs (30d)
- 40
Description
Environment
nitropack: latest
compatibilityDate: "2025-03-04"
Node.js: v20.18.3
Reproduction
import { Buffer } from 'node:buffer'
import { SerialPort } from 'serialport'
export default defineNitroPlugin(() => {
const port = new SerialPort({
path: 'COM3',
baudRate: 115200,
})
port
.on('data', (data) => {
console.log((data as Buffer).toString('utf-8'))
})
port.write(Buffer.from('Hi me!'))
})
When receive any data from serial (whatever using plugin or eventHandler), it will panic.
Describe the bug
When receiving data by using serialport, we have a error:
FATAL ERROR: HandleScope::HandleScope Entering the V8 API without proper locking in place
Error details
FATAL ERROR: HandleScope::HandleScope Entering the V8 API without proper locking in place
----- Native stack trace -----
1: 00007FF6BA90738B node::SetCppgcReference+19771
2: 00007FF6BA877DF9 node::OnFatalError+265
3: 00007FF6BB2E5929 v8::HandleScope::Initialize+137
4: 00007FF6BB2CDC2E v8::HandleScope::HandleScope+14
5: 00007FF6BA8CF99A napi_open_handle_scope+154
6: 00007FFA3677A0E0 napi_register_module_v1+9744
7: 00007FF6BA96CD2B uv_update_time+491
8: 00007FF6BA96C8A4 uv_run+900
9: 00007FF6BA93D7A5 node::SpinEventLoop+405
10: 00007FF6BA824392 OSSL_STORE_LOADER_get0_description+153698
11: 00007FF6BA8BB26D node::Start+4957
12: 00007FF6BA8B9F40 node::Start+48
13: 00007FF6BA66D9BC AES_cbc_encrypt+151532
14: 00007FF6BBB0848C inflateValidate+19196
15: 00007FFA6BC97374 BaseThreadInitThunk+20
16: 00007FFA6D13CC91 RtlUserThreadStart+33
FATAL ERROR: v8::HandleScope::CreateHandle() Cannot create a handle without a HandleScope
----- Native stack trace -----
1: 00007FF6BA90738B void __cdecl node::SetCppgcReference(class v8::Isolate * __ptr64,class v8::Local<class v8::Object>,void * __ptr64)+19771
2: 00007FF6BA877DF9 void __cdecl node::OnFatalError(char const * __ptr64,char const * __ptr64)+265
3: 00007FF6BB2F162B public: void __cdecl v8::FunctionTemplate::RemovePrototype(void) __ptr64+331
4: 00007FF6BB187896 public: struct v8::WrapperDescriptor __cdecl v8::CppHeap::wrapper_descriptor(void)const __ptr64+64918
5: 00007FF6BB2CDB24 public: __cdecl v8::EscapableHandleScope::EscapableHandleScope(class v8::Isolate * __ptr64) __ptr64+52
6: 00007FF6BA876E69 DSA_meth_get_flags+89289
7: 00007FF6BA9072A2 void __cdecl node::SetCppgcReference(class v8::Isolate * __ptr64,class v8::Local<class v8::Object>,void * __ptr64)+19538
8: 00007FF6BA877E0B void __cdecl node::OnFatalError(char const * __ptr64,char const * __ptr64)+283
9: 00007FF6BB2E5929 protected: void __cdecl v8::HandleScope::Initialize(class v8::Isolate * __ptr64) __ptr64+137
11: 00007FF6BA8CF99A napi_open_handle_scope+154
12: 00007FFA3677A0E0 napi_register_module_v1+9744
13: 00007FF6BA96CD2B uv_update_time+491
14: 00007FF6BA96C8A4 uv_run+900
15: 00007FF6BA93D7A5 class v8::Maybe<int> __cdecl node::SpinEventLoop(class node::Environment * __ptr64)+405
16: 00007FF6BA824392 X509_STORE_get_cleanup+153698
17: 00007FF6BA8BB26D int __cdecl node::Start(int,char * __ptr64 * __ptr64 const)+4957
18: 00007FF6BA8B9F40 int __cdecl node::Start(int,char * __ptr64 * __ptr64 const)+48
19: 00007FF6BA66D9BC AES_cbc_encrypt+151532
20: 00007FF6BBB0848C inflateValidate+19196
21: 00007FFA6BC97374 BaseThreadInitThunk+20
22: 00007FFA6D13CC91 RtlUserThreadStart+33
ELIFECYCLE Command failed with exit code 134.
Additional context
serialport is a js lib based on nodejs, which is usually used for serial communication.
The repro code above works well if using node xxx.mjs to boot it. So I guess maybe I cannot use serialport or even Node.js in Nitro directly like this?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the TypeScript Nitro plugin and eventHandler reproduction using Node.js v20.18.3 and serialport, then compare it with the working node xxx.mjs execution described in the issue. Reproduce the native V8 locking crash and trace the differing runtime path; done means identifying the supported integration behavior and providing a verified fix or clear limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100