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); }