Repository navigation
REPL doesn't work with nested proxies #57829
Description
Activity
- addedreplIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.
on Apr 11, 2025 I guess it is related to the input preview triggering util.inspect on it.
I'm pretty sure this is caused by the REPL completer 🤔
Example
The following code reproduces the issue:
const repl = require('node:repl'); const r = repl.start(); r.write(` const handler = { get(target, prop, receiver) { console.log(\`Accessed prop: \${String(prop)}\`); return new Proxy(function () {}, { apply: function (_target, _thisArg, args) { console.log(\`Called function: \${String(prop)} with args:\`, args); return \`Result of calling \${prop}\`; }, get: function (_target, subProp) { console.log(\`Accessed nested prop: \${String(subProp)} on \${String(prop)}\`); return \`Nested value of \${subProp}\`; } }); } }; const obj = new Proxy({}, handler); `);
(+ typing
obj.hello.worldof course)But the following, where the completer if overridden by a noop function does not:
const repl = require('node:repl'); const r = repl.start({ completer: () => { return [[], '']; }, }); r.write(` const handler = { get(target, prop, receiver) { console.log(\`Accessed prop: \${String(prop)}\`); return new Proxy(function () {}, { apply: function (_target, _thisArg, args) { console.log(\`Called function: \${String(prop)} with args:\`, args); return \`Result of calling \${prop}\`; }, get: function (_target, subProp) { console.log(\`Accessed nested prop: \${String(subProp)} on \${String(prop)}\`); return \`Nested value of \${subProp}\`; } }); } }; const obj = new Proxy({}, handler); `);
(+ typing
obj.hello.worldof course)Actually based on the following code comment I think that this is a known limitation/issue
Lines 1314 to 1315 in 09ecd2e
// Warning: This eval's code like "foo.bar.baz", so it will run property // getter code. Yeah here it is:
Line 1519 in 09ecd2e
this.eval(evalExpr, this.context, getREPLResourceName(), (e, obj) => { this is the eval triggering the getter...
mh... I can't imagine how this could be fixed... besides maybe disabling the completer on nested object fields
would that be a valid tradeoff? maybe it could be done behind a flag? 🤔
Can we close this issue, @dario-piotrowicz ?
Hey @geeksilva97 🙂
In #57909 we decided that there's still some work to do around REPL tab completion (see: #57909 (comment)).
So that's why my PR didn't close this issue.
I'm planning to improve the REPL tab completion check more (after #58775) before closing this if that works for you, or if you prefer (since the specific bug your issue referred to has been fixed) we can close this issue and I can open a new one for the extra work, whatever you prefer 🙂
Nah, we're good. Let's leave it open until it is finished. Thank you.
Reacted by Dario PiotrowiczReacted by Dario PiotrowiczThis got fully resolved by now. Closing as fixed
Reacted by Edy Silva

Version
23.10.0
Platform
Subsystem
repl
What steps will reproduce the bug?
node)obj.hello.world.How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
It should allow me to type something like
obj.hello.world.What do you see instead?
I can type
obj.hellobut once I type the other dot, it already triggers the proxy. See the video:node-repl-proxy-issue.mov
Additional information
No response