镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Description

@wrynegade

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.

Activity

  1. JckXia commented on May 24, 2022

    @JckXia
    Member

    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?

  2. wrynegade commented on May 24, 2022

    @wrynegade
    Author

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

  3. wrynegade commented on May 25, 2022

    @wrynegade
    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
  4. added
    reportIssues and PRs related to Node.js diagnostic reports.
    on May 25, 2022
  5. targos commented on May 25, 2022

    @targos
    Member

    @nodejs/diagnostics

  6. F3n67u commented on May 27, 2022

    @F3n67u
    Contributor

    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.

  7. wrynegade commented on May 27, 2022

    @wrynegade
    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.

  8. F3n67u commented on May 27, 2022

    @F3n67u
    Contributor

    @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.

  9. added a commit that references this issue on Jul 12, 2022
  10. added a commit that references this issue on Jul 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    reportIssues and PRs related to Node.js diagnostic reports.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions