Skip to content

Commit 38f894c

Browse files
committed
repl: add ImportExpression to disallow list of speculative evaluation
REPL speculative completeions were allowing ImportExpression to be egarly evaluated, which caused the REPL to try importing invalid modules which would cause the REPL to get stuck in a loop of trying to import the module and failing causing it to lock up. This commit makes it so that ImportExpression are disallowed from being evaluated in that case. Fixes: nodejs#64523 Signed-off-by: BlankParticle <[email protected]>
1 parent cf882a7 commit 38f894c

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎lib/internal/repl/completion.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ function findExpressionCompleteTarget(code) {
629629
ForInStatement: disallow,
630630
ForOfStatement: disallow,
631631
CallExpression: disallow,
632+
ImportExpression: disallow,
632633
AssignmentExpression: disallow,
633634
UpdateExpression: disallow,
634635
});

‎test/parallel/test-repl-tab-complete.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,4 +562,14 @@ describe('REPL tab completion (core functionality)', () => {
562562

563563
replServer.close();
564564
});
565+
566+
it('does not evaluate dynamic imports for completion', () => {
567+
const { replServer } = startNewREPLServer({
568+
eval: common.mustNotCall(),
569+
});
570+
571+
replServer.complete('import("").', getNoResultsFunction());
572+
573+
replServer.close();
574+
});
565575
});

0 commit comments

Comments
 (0)