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

Pasting very long strings freezes node REPL on MacOS #43343

Open
JoBrad opened this issue Jun 8, 2022 · 3 comments
Open

Pasting very long strings freezes node REPL on MacOS #43343

JoBrad opened this issue Jun 8, 2022 · 3 comments
Labels
macos Issues and PRs related to the macOS platform / OSX. repl Issues and PRs related to the REPL subsystem.

Comments

@JoBrad
Copy link

JoBrad commented Jun 8, 2022

Version

18.3.0

Platform

Darwin SoMuchBiggerOnTheInside-2.local 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64 x86_64

Subsystem

No response

What steps will reproduce the bug?

  • Open iTerm2 version 3.4.15 and start a new node REPL session.
  • Ignoring the comment on the first line, copy the first 3,500 characters of the jQuery v3.6.0 minified library (https://code.jquery.com/jquery-3.6.0.min.js) into the REPL. The REPL will freeze.
  • Open a new tab, start a new node REPL, and paste ~2,000 characters of the library into the REPL. The code will be cut short. You can copy and paste new chunks of text into the REPL, as long as you keep your text less than ~2,000 - 3,500 characters in length. However if you paste more than that, the REPL will freeze.
  • Use this formatter to format the jquery library (don't make any changes to the default settings for the formatter): https://webformatter.com/javascript
  • Paste the first 128 lines into the REPL (including the first comment line). This is 3,906 characters. The REPL will display errors and only show part of the code you have pasted, but will not freeze.
  • The 129th line is the beginning of a for statement. Copying all of the text up until the end of the keyword for (but before the () and pasting this into the REPL will cause it to freeze. If you only copy a part of the word for it won't freeze.

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

I can replicate these symptoms every time. Note that I can paste the entire jQuery library into a Python REPL (in the same iTerm2 tab) without any freezing at all. The fact that the for keyword changes behavior makes me think the error is happening when parsing the language. It may be a regression of #32999 (or a similar bug, for Macs), but pasting the 1000 "a" commands in the gist below (mentioned in #32999 comments) does not cause the REPL to freeze.

https://gist.githubusercontent.com/bzoz/bba634114402fee35554f4972a0887b6/raw/c71217ab21ecdf8d6e0874e955fe3b780df4e89f/aaaaaa.txt

What is the expected behavior?

I expect the REPL to accept the pasted text.

What do you see instead?

The REPL freezes or only shows part of the pasted text.

Additional information

No response

@mscdex
Copy link
Contributor

mscdex commented Jun 8, 2022

Possibly a duplicate of #40626

@VoltrexKeyva VoltrexKeyva added repl Issues and PRs related to the REPL subsystem. macos Issues and PRs related to the macOS platform / OSX. labels Jun 8, 2022
@JoBrad
Copy link
Author

JoBrad commented Jun 8, 2022

Not a duplicate. My REPL isn’t reacting slowly, it’s completely freezing and is unresponsive. For instance, when passing the first 128 lines of the jQuery library, the paste operation is pretty quick.

@mscdex
Copy link
Contributor

mscdex commented Jun 8, 2022

Both issues are about performance issues with pasting very long lines into the REPL. The REPL implementation currently has to continuously re-scan the entire line buffer after every chunk it receives, which is why it's not a problem with short lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
macos Issues and PRs related to the macOS platform / OSX. repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

No branches or pull requests

3 participants