uNetworking/uWebSockets.js

FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal

dimdenGD opened this issue · 1 comments

Running this code:

import uWS from 'uWebSockets.js';

class Application {
    #app;
    constructor(options) {
        this.#app = uWS.App(options);
    }

    listen(port, callback) {
        this.#app.listen(port, callback);
    }
}

const app = new Application();

app.listen(3000, () => {
    console.log('Server is running on port 3000');
});

Gives this error:

FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal
----- Native stack trace -----

 1: 00007FF6478F39EB node::SetCppgcReference+18459
 2: 00007FF647863379 node::OnFatalError+265
 3: 00007FF6482E5B63 v8::api_internal::ToLocalEmpty+83
 4: 00007FFD23493E24
 5: 00007FFD234B0EEA node::ArrayBufferAllocator::~ArrayBufferAllocator+96202
 6: 00007FF648292C5E v8::SharedValueConveyor::SharedValueConveyor+416270
 7: 00007FF64829285A v8::SharedValueConveyor::SharedValueConveyor+415242
 8: 00007FF648292B1F v8::SharedValueConveyor::SharedValueConveyor+415951
 9: 00007FF648292990 v8::SharedValueConveyor::SharedValueConveyor+415552
10: 00007FF64838DFFE v8::PropertyDescriptor::writable+677838
11: 00007FF6482FF6A0 v8::PropertyDescriptor::writable+93808
12: 00007FF6482FCBE6 v8::PropertyDescriptor::writable+82870
13: 00007FF64844A406 v8::PropertyDescriptor::writable+1448918
14: 00007FF6482FF6A0 v8::PropertyDescriptor::writable+93808
15: 00007FF64833AB51 v8::PropertyDescriptor::writable+336673
16: 00007FF6482FDA60 v8::PropertyDescriptor::writable+86576
17: 00007FF6482FD65B v8::PropertyDescriptor::writable+85547
18: 00007FF6481A7BD8 v8::StackTrace::GetFrameCount+3928
19: 00007FF6481A7D0B v8::StackTrace::GetFrameCount+4235
20: 00007FF6481A896D v8::StackTrace::GetFrameCount+7405
21: 00007FF647ED8072 v8::base::Thread::StartSynchronously+407106
22: 00007FF647EDA852 v8::base::Thread::StartSynchronously+417314
23: 00007FF647ED7990 v8::base::Thread::StartSynchronously+405344
24: 00007FF647F0D827 v8::base::Thread::StartSynchronously+626167
25: 00007FF6482C51AD v8::Module::Evaluate+621
26: 00007FF6478AA506 v8::base::CPU::has_idiva+8774
27: 00007FF648292C5E v8::SharedValueConveyor::SharedValueConveyor+416270
28: 00007FF64829285A v8::SharedValueConveyor::SharedValueConveyor+415242
29: 00007FF648292B1F v8::SharedValueConveyor::SharedValueConveyor+415951
30: 00007FF648292990 v8::SharedValueConveyor::SharedValueConveyor+415552
31: 00007FF64838DFFE v8::PropertyDescriptor::writable+677838
32: 00007FF6482FF6A0 v8::PropertyDescriptor::writable+93808
33: 00007FF648337B07 v8::PropertyDescriptor::writable+324311
34: 00007FF6483F00B5 v8::PropertyDescriptor::writable+1079429
35: 00007FF648327745 v8::PropertyDescriptor::writable+257813
36: 00007FF6482FD95B v8::PropertyDescriptor::writable+86315
37: 00007FF6481A7BEF v8::StackTrace::GetFrameCount+3951
38: 00007FF6481A7D0B v8::StackTrace::GetFrameCount+4235
39: 00007FF6481A8AFA v8::StackTrace::GetFrameCount+7802
40: 00007FF64817FCC2 v8::base::CPU::has_sse41+1410
41: 00007FF64817FA0C v8::base::CPU::has_sse41+716
42: 00007FF64792A852 node::CallbackScope::~CallbackScope+418
43: 00007FF64792A71E node::CallbackScope::~CallbackScope+110
44: 00007FF6477E9AE0 X509_STORE_get_cleanup+4816
45: 00007FF6477E8486 node::TriggerNodeReport+82278
46: 00007FF6477E8135 node::TriggerNodeReport+81429
47: 00007FF647929FD4 node::SpinEventLoop+436
48: 00007FF64780E6C2 X509_STORE_get_cleanup+155314
49: 00007FF6478A7F6D node::Start+4909
50: 00007FF6478A6C70 node::Start+48
51: 00007FF64765D7BC AES_cbc_encrypt+151020
52: 00007FF648AF28EC inflateValidate+19196
53: 00007FFD93C9257D BaseThreadInitThunk+29
54: 00007FFD94A6AF28 RtlUserThreadStart+40

----- JavaScript stack trace -----

1: Application (file:///D:/JS/server/src/application.js:6:25)
2: file:///D:/JS/server/src/application.js:14:13
3: run (node:internal/modules/esm/module_job:234:25)

But if I run this code instead:

import uWS from 'uWebSockets.js';

const app = uWS.App();

app.listen(3000, () => {
    console.log('Server is running on port 3000');
});

It works fine. So for some reason uWS doesn't work when it's inside class? Also tested a bit more and it doesn't work when it's inside a function too. I'm using Node.js 20.17.0 and uWS v20.48.0 on Windows 11.

Oh! It's apparently sending undefined as options causing this. I guess it should still handle it properly to avoid confusion, so I'll leave the issue open.