nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
107.6k stars 29.6k forks source link

FATAL ERROR: v8::FromJust Maybe value is Nothing #43304

Open RatanRSur opened 2 years ago

RatanRSur commented 2 years ago

Version

v16.14.0

Platform

Darwin 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64

Subsystem

No response

What steps will reproduce the bug?

Running yarn test in debug console in visual studio code

How often does it reproduce? Is there a required condition?

Everytime

What is the expected behavior?

No response

What do you see instead?

FATAL ERROR: v8::FromJust Maybe value is Nothing.
 1: 0x10415a260 node::Abort() [/Users/rai/.nvm/versions/node/v16.14.0/bin/node]
 2: 0x10415a3e8 node::errors::TryCatchScope::~TryCatchScope() [/Users/rai/.nvm/versions/node/v16.14.0/bin/node]
 3: 0x1042aabc8 v8::V8::FromJustIsNothing() [/Users/rai/.nvm/versions/node/v16.14.0/bin/node]
 4: 0x104203174 node::ReportWritesToJSStreamListener::OnStreamAfterReqFinished(node::StreamReq*, int) [/Users/rai/.nvm/versions/node/v16.14.0/bin/node]
 5: 0x1042031d0 node::ShutdownWrap::OnDone(int) [/Users/rai/.nvm/versions/node/v16.14.0/bin/node]
 6: 0x104207640 node::LibuvStreamWrap::AfterUvShutdown(uv_shutdown_s*, int) [/Users/rai/.nvm/versions/node/v16.14.0/bin/node]
 7: 0x1049d53e8 uv__stream_io [/Users/rai/.nvm/versions/node/v16.14.0/bin/node]
 8: 0x1049dcf70 uv__io_poll [/Users/rai/.nvm/versions/node/v16.14.0/bin/node]
 9: 0x1049cb688 uv_run [/Users/rai/.nvm/versions/node/v16.14.0/bin/node]
10: 0x1040a7ccc node::SpinEventLoop(node::Environment*) [/Users/rai/.nvm/versions/node/v16.14.0/bin/node]
11: 0x1041ec598 node::worker::Worker::Run() [/Users/rai/.nvm/versions/node/v16.14.0/bin/node]
12: 0x1041ef7c0 node::worker::Worker::StartThread(v8::FunctionCallbackInfo<v8::Value> const&)::$_3::__invoke(void*) [/Users/rai/.nvm/versions/node/v16.14.0/bin/node]
13: 0x18afec26c _pthread_start [/usr/lib/system/libsystem_pthread.dylib]
14: 0x18afe708c thread_start [/usr/lib/system/libsystem_pthread.dylib]

Additional information

No response

airtable-keyhanvakil commented 2 years ago

Possibly already fixed in #42874.

ashishchandr70 commented 2 years ago

Do you know @airtable-keyhanvakil where this landed i.e. which version was it applied to and whether it covers Node.js 14.x?

airtable-keyhanvakil commented 2 years ago

@ashishchandr70 It looks to be in v18.2.0. I asked about how to get it backported to earlier branches in that PR.

Radinax commented 2 years ago

I had this issue with vitest, I just updated it to the latest version "vitest": "^0.22.1" and it works now

OmgImAlexis commented 2 years ago

Similar issue yet again in vitest@0.23.1 on node@v18.3.0.

This happened after hitting RangeError: Maximum call stack size exceeded in one of my tests.

FATAL ERROR: v8::FromJust Maybe value is Nothing.
 1: 00007FF7A83C94EF node_api_throw_syntax_error+174703
 2: 00007FF7A83579C6 v8::internal::wasm::WasmCode::safepoint_table_offset+67350
 3: 00007FF7A835889D node::OnFatalError+301
 4: 00007FF7A8DD5335 v8::api_internal::FromJustIsNothing+53
 5: 00007FF7A83F1AE0 node::UVException+912
 6: 00007FF7A8341EC9 v8::base::CPU::has_fpu+44745
 7: 00007FF7A842B297 uv_timer_stop+1207
 8: 00007FF7A842783B uv_async_send+331
 9: 00007FF7A8426FCC uv_loop_init+1292
10: 00007FF7A842716A uv_run+202
11: 00007FF7A83F6065 node::SpinEventLoop+309
12: 00007FF7A828D200 v8::internal::wasm::SignatureMap::Freeze+36000
13: 00007FF7A8288918 v8::internal::wasm::SignatureMap::Freeze+17336
14: 00007FF7A841783D uv_poll_stop+557
15: 00007FF7A93D0D70 v8::internal::compiler::ToString+145936
16: 00007FFBAAFD458D BaseThreadInitThunk+29
17: 00007FFBACE57558 RtlUserThreadStart+40

Original comment: https://github.com/nodejs/node/issues/6899#issuecomment-1179984325

targos commented 2 years ago

It would be useful if someone could provide a simple way to reproduce the crash.

ImLunaHey commented 1 year ago

Here's a small reproducible code sample. This crashes with the error 1/5 times for me. If I keep running this over and over I consistently get the crash.

import { createApplication, Request } from '@nbit/bun';
import { expect, test } from 'vitest';

const home = () => ({ hello: 'world' });

const { defineRoutes, createRequestHandler } = createApplication();

const routes = defineRoutes(app => [
    app.get('/', home),
]);

const requestHandler = createRequestHandler(routes);

test('should return the home page', async () => {
    const request = new Request('http://localhost/');
    const response = await requestHandler(request);
    expect(response.status).toBe(200);
});
➜  vote git:(main) ✗ bun run test
$ vitest run --coverage

 RUN  v0.34.1 /Users/xo/code/ImLunaHey/vote
      Coverage enabled with v8

 ✓ src/handlers/home.test.ts (1)
   ✓ should return the home page

 Test Files  1 passed (1)
      Tests  1 passed (1)
   Start at  20:40:20
   Duration  754ms (transform 77ms, setup 0ms, collect 77ms, tests 8ms, environment 0ms, prepare 160ms)

 % Coverage report from v8
-----------------------|---------|----------|---------|---------|-------------------
File                   | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-----------------------|---------|----------|---------|---------|-------------------
All files              |       0 |        0 |       0 |       0 |                   
 src                   |       0 |        0 |       0 |       0 |                   
  application.ts       |       0 |        0 |       0 |       0 | 1-9               
  index.ts             |       0 |        0 |       0 |       0 | 1-11              
  things-to-vote-on.ts |       0 |        0 |       0 |       0 | 1-90              
 src/handlers          |       0 |        0 |       0 |       0 |                   
  home.ts              |       0 |        0 |       0 |       0 | 1-22              
  index.ts             |       0 |        0 |       0 |       0 | 1-2               
  vote.tsx             |       0 |        0 |       0 |       0 | 1-135             
-----------------------|---------|----------|---------|---------|-------------------
FATAL ERROR: v8::FromJust Maybe value is Nothing.
 1: 0x10e451a95 node::Abort() (.cold.1) [/Users/xo/.nvm/versions/node/v18.3.0/bin/node]
 2: 0x10cf19419 node::Abort() [/Users/xo/.nvm/versions/node/v18.3.0/bin/node]
 3: 0x10cf1958f node::OnFatalError(char const*, char const*) [/Users/xo/.nvm/versions/node/v18.3.0/bin/node]
 4: 0x10d0a2c60 v8::api_internal::FromJustIsNothing() [/Users/xo/.nvm/versions/node/v18.3.0/bin/node]
 5: 0x10cf1ca94 node::fs::FileHandle::CloseReq::Resolve() [/Users/xo/.nvm/versions/node/v18.3.0/bin/node]
 6: 0x10cf31e4a node::fs::FileHandle::ClosePromise()::$_0::__invoke(uv_fs_s*) [/Users/xo/.nvm/versions/node/v18.3.0/bin/node]
 7: 0x10d9cc578 uv__work_done [/Users/xo/.nvm/versions/node/v18.3.0/bin/node]
 8: 0x10d9d173b uv__async_io [/Users/xo/.nvm/versions/node/v18.3.0/bin/node]
 9: 0x10d9e552b uv__io_poll [/Users/xo/.nvm/versions/node/v18.3.0/bin/node]
10: 0x10d9d1cc1 uv_run [/Users/xo/.nvm/versions/node/v18.3.0/bin/node]
11: 0x10ce49f9f node::SpinEventLoop(node::Environment*) [/Users/xo/.nvm/versions/node/v18.3.0/bin/node]
12: 0x10cfc64d8 node::worker::Worker::Run() [/Users/xo/.nvm/versions/node/v18.3.0/bin/node]
13: 0x10cfc9e22 node::worker::Worker::StartThread(v8::FunctionCallbackInfo<v8::Value> const&)::$_3::__invoke(void*) [/Users/xo/.nvm/versions/node/v18.3.0/bin/node]
14: 0x7ff81004c4e1 _pthread_start [/usr/lib/system/libsystem_pthread.dylib]
15: 0x7ff810047f6b thread_start [/usr/lib/system/libsystem_pthread.dylib]
error: script "test" exited with code 6 (SIGABRT)
bnoordhuis commented 1 year ago

@ImLunaHey can you try with the latest v18.x? v18.3.0 is pretty old by now.

A test case without third-party dependencies would help too. import "vitest" probably pulls in the world and then some.

ImLunaHey commented 1 year ago

I believe vitest is part of the issue. Running this in node or bun with node or bun's built-in testing framework for example doesn't produce this error.

madeleineostoja commented 12 months ago

@ImLunaHey does disabling multi threading (vitest run --coverage --no-threads) fix the issue? And does removing --coverage fix it? Both of those hacks worked for me, wondering if there's an issue with multithreading and coverage in vitest

intellild commented 4 weeks ago

I join the problem with 20.15.1