Skip to content

Commit

Permalink
fix(RemoteRequestHandler): handle socket disconnects
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Dec 12, 2024
1 parent 57ab678 commit c069b25
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/core/handlers/RemoteRequestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ export class RemoteRequestHandler extends RequestHandler<
this.contextId,
)

// If the socket is disconnected, or gets disconnected,
// skip this remote handler and continue with the request locally.
if (this.socket.disconnected) {
console.log(
'[RemoteRequestHandler] socket already disconnected, skipping...',
)

return {
...parsedResult,
response: undefined,
}
}

this.socket.once('disconnect', () => {
console.log('[RemoteRequestHandler] socket disconnected, skipping...')
responsePromise.resolve(undefined)
})

/**
* @note Remote request handler is special.
* It cannot await the mocked response from the remote process in
Expand Down

0 comments on commit c069b25

Please sign in to comment.