Skip to content

Commit

Permalink
fix: Reject any pending commands on connection close (#943)
Browse files Browse the repository at this point in the history
  • Loading branch information
zobo committed Jul 15, 2024
1 parent f1dc59f commit a4f92b9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/xdebugConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,13 @@ export class Connection extends DbgpConnection {
}
}
})
this.on('close', () => this._initPromiseRejectFn(new Error('connection closed (on close)')))
this.on('close', () => {
this._pendingCommands.forEach(command => command.rejectFn(new Error('connection closed (on close)')))
this._pendingCommands.clear()
this._commandQueue.forEach(command => command.rejectFn(new Error('connection closed (on close)')))
this._commandQueue = []
this._initPromiseRejectFn(new Error('connection closed (on close)'))
})
}

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

0 comments on commit a4f92b9

Please sign in to comment.