Skip to content

Commit

Permalink
refactor(rpc): make sure errored is called for all errors
Browse files Browse the repository at this point in the history
  • Loading branch information
marcj committed May 16, 2024
1 parent 0fc2bd4 commit 97e65ec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/rpc/src/client/client-websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class RpcWebSocketClientAdapter implements ClientTransportAdapter {
socket.onclose = (event) => {
if (errored) {
const reason = `code ${event.code} reason ${event.reason || 'unknown'}`;
const message = connected ? `abnormal error` : `Could not connect: ${reason}`;
const message = connected ? `abnormal error: ${reason}` : `Could not connect: ${reason}`;
connection.onError(new Error(message));
} else {
connection.onClose();
Expand Down
8 changes: 1 addition & 7 deletions packages/rpc/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,7 @@ export class RpcClientTransporter {
}

protected onError(error: Error) {
if (this.connected) {
// We do not want to call errored if we are not yet connected,
// since errors thrown while in connection process are forwarded
// to the connection promise (and thus are thrown in connect()
// or in any rpc action).
this.errored.next({ connectionId: this.connectionId, error });
}
this.errored.next({ connectionId: this.connectionId, error });
this.onDisconnect();
}

Expand Down

0 comments on commit 97e65ec

Please sign in to comment.