-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
node inspect crashes when tab-completing with a require #41793
Comments
@jkrems Should this bug report be transferred to https://github.com/nodejs/node-inspect? Or is this the better location for it? |
I think it would be best to transfer it to |
Done! |
I had the same problem, the cause was using vm context: |
I'm unable to reproduce this bug. @langdon-holly Are you still seeing this issue in Node.js 16.x or 14.x? |
@Trott I am unable to reproduce in v16.0.0. |
I was using 14.15.0 |
This code is failing on LTS (tested on 14.15.0 / 14.16.1) with the problem reported: const repl = require('repl');
const r = repl.start('teste> ');
const context = { x: 1, y: 2 };
r.context = require('vm').createContext(context); It's the first time I create my own REPL so could be my mistake... But if the problem is just with the auto-complete, if it was caught we could still require (without auto-complete) and continue to use the REPL. This works... const repl = require('repl');
const r = repl.start('teste> ');
r.context.x = 1;
r.context.y = 2; |
Is there any better way to make a complex context from an object to use in REPL? |
@langdon-holly I'm curious if this might be Linux distribution and/or processor specific. I just installed an Ubuntu docker image on macOS, then used |
I doubt it's processor-specific, but it could be OS-specific. I just tried node v11.1.0 on Arch Linux, again, and was able to reproduce. I also briefly looked at the source code, and it appears that the crash occurs at repl.js:1031 when completing a require, when the REPLServer's context has no 'require' property. Perhaps the OS or installation details affect the REPLServer's context? |
I'm running on ubuntu 20 here. Installed Node via ASDF. |
For the original bug ( The exception looks like the REPL code to auto-complete require paths blindly assumes that any Line 1228 in a03d3af
The require function in the command line API is set up here: node/lib/internal/util/inspector.js Lines 25 to 37 in a03d3af
|
@nodejs/repl |
Steps to reproduce:
node inspect test.js
require("
Result: Node prints the following message to standard error, then exits with status 1.
Observed rules for reproduction:
require("
may be preceded by any JavaScript code.require
and("
.The text was updated successfully, but these errors were encountered: