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

JSON Parse error in internal/process/report? #43193

Closed
wrynegade opened this issue May 23, 2022 · 7 comments
Closed

JSON Parse error in internal/process/report? #43193

wrynegade opened this issue May 23, 2022 · 7 comments
Labels
report Issues and PRs related to process.report.

Comments

@wrynegade
Copy link

wrynegade commented May 23, 2022

Version

% node -v
v18.2.0

Platform

% uname -a
Linux 5.17.9-arch1-1 #1 SMP PREEMPT Wed, 18 May 2022 17:30:11 +0000 x86_64 GNU/Linux

Subsystem

process.report.getReport

What steps will reproduce the bug?

1 Step: Run process.report.getReport()

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

I can only reproduce this on the current machine. Two other machines on the same architecture and node version appear unaffected.

Full reinstall of node had no effect.

What is the expected behavior?

No response

What do you see instead?

> process.report.getReport()
Uncaught SyntaxError: Unexpected token v in JSON at position 10540

Additional information

I looked through source and don't understand how this report is generated, so I don't know how to debug.

This prevents me from building a variety of node projects on this machine and only started after an upgrade from v17.

@JckXia
Copy link
Member

JckXia commented May 24, 2022

Just a shot in the dark. But it looks like the function WriteNodeReport from src/node_report.cc on line 184 is doing the report data collection. I'd compile v18.2.0 from the source and see if you can replicate this issue. If so it might be a good idea to start debugging from that function.

Though this looks like an error thrown by JS. This function https://github.com/nodejs/node/blob/master/lib/internal/process/report.js#L32 seems to also deal with the report generation. What if you add a few console logs there to see if that's where it is happening?

@wrynegade
Copy link
Author

I'll give that a try and report back; thanks for the suggestion!

@wrynegade
Copy link
Author

Big thanks to @JckXia for helping me track this down.

It seems that this error happens when the vertical tab byte ^K is somewhere in the environment. This causes PrintSystemInformation to die (src/node_report line 708).

Weird that other binary bytes seem to be escaped appropriately. That said, the problem is now reproducible. Being sure to use the binary byte (not characters ^ and K):

% FOO='^K'
% node
> process.report.getReport();
Uncaught SyntaxError: Unexpected token v in JSON at position 10157

@targos targos added the report Issues and PRs related to process.report. label May 25, 2022
@targos
Copy link
Member

targos commented May 25, 2022

@nodejs/diagnostics

@F3n67u
Copy link
Member

F3n67u commented May 27, 2022

Being sure to use the binary byte (not characters ^ and K):

@wrynegade I have a maybe silly question, could you share how to type binary byte (not characters ^ and K)? I am on mac.

@wrynegade
Copy link
Author

@wrynegade I have a maybe silly question, could you share how to type binary byte (not characters ^ and K)? I am on mac.

Of course! I don't have a macbook to test specifically, but this is the byte sent by pressing CTRL + K.

Typing this character as a byte literal will depend largely on your editor and system. In a terminal emulator you can type CTRL + V (to insert the next character sequence as a literal) then CTRL + K.

@F3n67u
Copy link
Member

F3n67u commented May 27, 2022

@wrynegade I have a maybe silly question, could you share how to type binary byte (not characters ^ and K)? I am on mac.

Of course! I don't have a macbook to test specifically, but this is the byte sent by pressing CTRL + K.

Typing this character as a byte literal will depend largely on your editor and system. In a terminal emulator you can type CTRL + V (to insert the next character sequence as a literal) then CTRL + K.

Thank you! I made it. I could reproduce this problem now.

danielleadams pushed a commit that referenced this issue Jun 14, 2022
PR-URL: #43206
Fixes: #43193
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this issue Jul 12, 2022
PR-URL: #43206
Fixes: #43193
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this issue Jul 31, 2022
PR-URL: #43206
Fixes: #43193
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
guangwong pushed a commit to noslate-project/node that referenced this issue Oct 10, 2022
PR-URL: nodejs/node#43206
Fixes: nodejs/node#43193
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
report Issues and PRs related to process.report.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants