Skip to content

Commit a4f92b9

Browse files
committed
fix: Reject any pending commands on connection close (#943)
1 parent f1dc59f commit a4f92b9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/xdebugConnection.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,13 @@ export class Connection extends DbgpConnection {
823823
}
824824
}
825825
})
826-
this.on('close', () => this._initPromiseRejectFn(new Error('connection closed (on close)')))
826+
this.on('close', () => {
827+
this._pendingCommands.forEach(command => command.rejectFn(new Error('connection closed (on close)')))
828+
this._pendingCommands.clear()
829+
this._commandQueue.forEach(command => command.rejectFn(new Error('connection closed (on close)')))
830+
this._commandQueue = []
831+
this._initPromiseRejectFn(new Error('connection closed (on close)'))
832+
})
827833
}
828834

829835
/** Returns a promise that gets resolved once the init packet arrives */

0 commit comments

Comments
 (0)