Be resilient against unexpected end of JSON input
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at Parser._flush (/Users/matteo/.nvm/versions/node/v10.14.2/lib/node_modules/clinic/node_modules/@nearform/trace-events-parser/index.js:58:24)
at Parser.prefinish (_stream_transform.js:141:10)
at Parser.emit (events.js:182:13)
at prefinish (_stream_writable.js:630:14)
at finishMaybe (_stream_writable.js:638:5)
at endWritable (_stream_writable.js:649:3)
at Parser.Writable.end (_stream_writable.js:589:5)
at ReadStream.onend (_stream_readable.js:628:10)
at Object.onceWrapper (events.js:273:13)
Same issue here:
node[26906]: ../src/tracing/node_trace_writer.cc:196:void node::tracing::NodeTraceWriter::AfterWrite(): Assertion `(write_req_.result) >= (0)' failed.
1: 0x10007e9b3 node::Abort() [/Users/adamtistler/.nvm/versions/node/v12.13.1/bin/node]
2: 0x10007e75b node::AppendExceptionLine(node::Environment*, v8::Local<v8::Value>, v8::Local<v8::Message>, node::ErrorHandlingMode) [/Users/adamtistler/.nvm/versions/node/v12.13.1/bin/node]
3: 0x10010ad92 node::tracing::NodeTraceWriter::InitializeOnThread(uv_loop_s*)::$_0::__invoke(uv_async_s*) [/Users/adamtistler/.nvm/versions/node/v12.13.1/bin/node]
4: 0x1008924d2 uv__work_done [/Users/adamtistler/.nvm/versions/node/v12.13.1/bin/node]
5: 0x100895bc9 uv__async_io [/Users/adamtistler/.nvm/versions/node/v12.13.1/bin/node]
6: 0x1008a684b uv__io_poll [/Users/adamtistler/.nvm/versions/node/v12.13.1/bin/node]
7: 0x100896056 uv_run [/Users/adamtistler/.nvm/versions/node/v12.13.1/bin/node]
8: 0x7fff6a920109 _pthread_start [/usr/lib/system/libsystem_pthread.dylib]
9: 0x7fff6a91bb8b thread_start [/usr/lib/system/libsystem_pthread.dylib]
process exited by signal SIGABRT
[ ] Analysing dataundefined:1
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at Parser._flush (/Users/adamtistler/.nvm/versions/node/v12.13.1/lib/node_modules/clinic/node_modules/@nearform/trace-events-parser/index.js:58:24)
at Parser.prefinish (_stream_transform.js:140:10)
at Parser.emit (events.js:210:5)
at prefinish (_stream_writable.js:645:14)
at finishMaybe (_stream_writable.js:653:5)
at endWritable (_stream_writable.js:673:3)
at Parser.Writable.end (_stream_writable.js:604:5)
at ReadStream.onend (_stream_readable.js:692:10)
at Object.onceWrapper (events.js:299:28)
Same issue here, can't sus this one out!
So this is caused by having '--trace-events-enabled', '--trace-event-categories', 'v8' where the doctor spawns the process. v18.14.2 btw.
Looks to be https://github.com/nodejs/node/issues/22042?
OK digging further this only happens in apps for us that include @google-cloud/resource-manager
Raised: https://github.com/googleapis/google-cloud-node/issues/4384 Not sure of the underlying cause however, hopefully the developers of that library will have a clue which helps others
Also raised https://github.com/nodejs/node/issues/48598, I think this is the root cause of the bug.
In doctor, it causes a SIGABRT because of this line: https://github.com/clinicjs/node-clinic-doctor/blob/00749d83f04cb30ed24e91f29e89ad25e267ac33/injects/sampler.js#L22
interestingly this isn't a problem on node16, only 18
interestingly this isn't a problem on node16, only 18
Currently experiencing this on latest versions of 16, 18, 20, and 21.