From a16deb399e49a15d06bdbf2a77ea973092cf3406 Mon Sep 17 00:00:00 2001 From: Divyanshu Sharma Date: Sun, 26 Jul 2026 22:25:48 +0530 Subject: [PATCH] repl: pass objectGroup to Runtime.awaitPromise When the inspector-backed REPL evaluates a promise-returning expression, Runtime.evaluate stores the remote promise object in an objectGroup. Runtime.awaitPromise did not pass objectGroup. Under GC pressure, the remote promise object could be collected before the await completed, causing the inspector to report: -32000: Promise was collected This surfaced in the REPL as ERR_INSPECTOR_COMMAND instead of the user's original exception. Pass objectGroup to Runtime.awaitPromise so the promise remains retained until the await completes. Fixes: https://github.com/nodejs/node/issues/64762 Signed-off-by: Divyanshu Sharma --- lib/internal/repl/inspector.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/internal/repl/inspector.js b/lib/internal/repl/inspector.js index 371255eac28ddb..c78a6a2d4a75eb 100644 --- a/lib/internal/repl/inspector.js +++ b/lib/internal/repl/inspector.js @@ -179,13 +179,16 @@ class ReplInspectorChannel { return response; } - // Hold the promise open until it resolves or rejects, - // so we can return the final value. + // Hold the promise open until it resolves or rejects. + // Pass objectGroup so the promise remote object stays retained for the + // duration of the await and cannot be collected by a GC cycle between + // the two inspector calls. return this.postInterruptible('Runtime.awaitPromise', { __proto__: null, promiseObjectId: response.result.objectId, returnByValue: params.returnByValue, generatePreview: params.generatePreview, + objectGroup: this.objectGroup, }, breakOnSigint); }