feat(v4.0.0-beta.5): BREAKING CHANGE: rename "error" event to "exception" to avoid unhandled exceptions

This commit is contained in:
tiagosiebler
2025-02-06 12:08:51 +00:00
parent a8f8d6bf15
commit 57b1a72b7f
10 changed files with 42 additions and 45 deletions

View File

@@ -62,7 +62,7 @@ export function waitForSocketEvent(
}
wsClient.on(event, (e) => resolver(e));
wsClient.on('error', (e) => rejector(e));
wsClient.on('exception', (e) => rejector(e));
// if (event !== 'close') {
// wsClient.on('close', (event) => {
@@ -78,21 +78,21 @@ export function waitForSocketEvent(
export function listenToSocketEvents(wsClient: WebsocketClient) {
const retVal: Record<
'update' | 'open' | 'response' | 'close' | 'error',
'update' | 'open' | 'response' | 'close' | 'exception',
typeof jest.fn
> = {
open: jest.fn(),
response: jest.fn(),
update: jest.fn(),
close: jest.fn(),
error: jest.fn(),
exception: jest.fn(),
};
wsClient.on('open', retVal.open);
wsClient.on('response', retVal.response);
wsClient.on('update', retVal.update);
wsClient.on('close', retVal.close);
wsClient.on('error', retVal.error);
wsClient.on('exception', retVal.exception);
return {
...retVal,
@@ -101,7 +101,7 @@ export function listenToSocketEvents(wsClient: WebsocketClient) {
wsClient.removeListener('response', retVal.response);
wsClient.removeListener('update', retVal.update);
wsClient.removeListener('close', retVal.close);
wsClient.removeListener('error', retVal.error);
wsClient.removeListener('exception', retVal.exception);
},
};
}