Skip to content

Commit a16deb3

Browse files
committed
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: #64762 Signed-off-by: Divyanshu Sharma <divyanshu88999@gmail.com>
1 parent 4a5eb1c commit a16deb3

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

lib/internal/repl/inspector.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,16 @@ class ReplInspectorChannel {
179179
return response;
180180
}
181181

182-
// Hold the promise open until it resolves or rejects,
183-
// so we can return the final value.
182+
// Hold the promise open until it resolves or rejects.
183+
// Pass objectGroup so the promise remote object stays retained for the
184+
// duration of the await and cannot be collected by a GC cycle between
185+
// the two inspector calls.
184186
return this.postInterruptible('Runtime.awaitPromise', {
185187
__proto__: null,
186188
promiseObjectId: response.result.objectId,
187189
returnByValue: params.returnByValue,
188190
generatePreview: params.generatePreview,
191+
objectGroup: this.objectGroup,
189192
}, breakOnSigint);
190193
}
191194

0 commit comments

Comments
 (0)