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

Repl fails to parse some json inputs #12447

Closed
sigmaSd opened this issue Oct 14, 2021 · 4 comments
Closed

Repl fails to parse some json inputs #12447

sigmaSd opened this issue Oct 14, 2021 · 4 comments
Labels
bug Something isn't working correctly repl related to the Read-Eval-Print-Loop functionality of Deno

Comments

@sigmaSd
Copy link
Contributor

sigmaSd commented Oct 14, 2021

Trying this line in the repl

JSON.parse('{"x": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa🌎"}')

fails with Unterminated string literal

It only fails if there is exactly 99 'a' (or any character) before the world unicode
If I add or remove a couple of characters before the unicode it works.

meta:
deno 1.14.3 (release, x86_64-unknown-linux-gnu)
v8 9.4.146.19
typescript 4.4.2

@andreubotella
Copy link
Contributor

Might be related to #10542

@lucacasonato lucacasonato added bug Something isn't working correctly repl related to the Read-Eval-Print-Loop functionality of Deno labels Oct 14, 2021
@lucacasonato
Copy link
Member

For reference, adding .x to the end of the statement makes it work again. Probably a bug in our object formatting code.

@lucacasonato lucacasonato self-assigned this Nov 22, 2021
@lucacasonato
Copy link
Member

Yeah, this looks like a combination of bugs in our object formatting code, and REPL code. Running this code demonstrates what is going on pretty well:

console.log(JSON.parse(`["98 chars", "${"x".repeat(98)}🌎"]`));
console.log(JSON.parse(`["99 chars", "${"x".repeat(99)}🌎"]`));
console.log(JSON.parse(`["100 chars", "${"x".repeat(100)}🌎"]`));
❯❯❯ deno run test.js
[
  "98 chars",
  "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx🌎"
]
[
  "99 chars",
  "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx�..."
]
[
  "100 chars",
  "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx..."
]

The formatted splits multi byte unicode chars in half. We need to do two things:

a) update formatting code to not chop multi byte characters in half
b) fix REPL so it doesn't error on surrogate pairs (this is actually an issue with our V8 inspector related code)

I'll keep this issue for a), while b) is already tracked in #12226

@sigmaSd
Copy link
Contributor Author

sigmaSd commented Jul 28, 2024

the issue seems fixed in the latest version, the reproduction code doesn't error anymore

@sigmaSd sigmaSd closed this as completed Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly repl related to the Read-Eval-Print-Loop functionality of Deno
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants