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

The Node REPL can't handle declaring a variable with the name util #38139

Closed
murgatroid99 opened this issue Apr 7, 2021 · 2 comments · Fixed by #38141
Closed

The Node REPL can't handle declaring a variable with the name util #38139

murgatroid99 opened this issue Apr 7, 2021 · 2 comments · Fixed by #38141
Labels
confirmed-bug Issues with confirmed bugs. repl Issues and PRs related to the REPL subsystem.

Comments

@murgatroid99
Copy link
Contributor

  • Version:14.15.4
  • Platform: Linux DESKTOP-OKC3QBQ 4.19.128-microsoft-standard deps: update openssl to 1.0.1j #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: REPL

What steps will reproduce the bug?

Run the node executable to open the REPL. In the REPL simply run the line const util = {}, then on the next line type the name of any existing symbol longer than 3 characters, such as process or module

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

This reproduction is consistent

What is the expected behavior?

The repl will continue to function normally.

What do you see instead?

The REPL overwrites most the typed line with the text (node:27986) TypeError: Cannot read property 'length' of undefined. Specifically, if I open the REPL and enter the input const util = {};<Enter>process, the REPL looks like this:

Welcome to Node.js v14.15.4.
Type ".help" for more information.
> const util = {};
undefined
> proc(node:28039) TypeError: Cannot read property 'length' of undefined
s(node:28039) TypeError: Cannot read property 'length' of undefined
@EladKeyshawn
Copy link

@murgatroid99 Can confirm on master. I'm taking a look into it.

@EladKeyshawn
Copy link

A added PR #38141 with a suggested fix. In short bad null check

@Ayase-252 Ayase-252 added the repl Issues and PRs related to the REPL subsystem. label Apr 8, 2021
@DerekNonGeneric DerekNonGeneric added the confirmed-bug Issues with confirmed bugs. label Apr 9, 2021
aduh95 pushed a commit to EladKeyshawn/node that referenced this issue Apr 18, 2021
The REPL no longer relies on `util` being a reference to the `util` core
module. It still relies on `globalThis` refering to the global object,
but no longer emits warnings when it's overwritten by the user.

PR-URL: nodejs#38141
Fixes: nodejs#38139
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants