fix(#192): potential crash if a ws network exception happens and there's no error listener in the client
This commit is contained in:
@@ -5,6 +5,10 @@ import { InverseClient } from './inverse-client';
|
|||||||
import { LinearClient } from './linear-client';
|
import { LinearClient } from './linear-client';
|
||||||
import { SpotClientV3 } from './spot-client-v3';
|
import { SpotClientV3 } from './spot-client-v3';
|
||||||
import { SpotClient } from './spot-client';
|
import { SpotClient } from './spot-client';
|
||||||
|
import { USDCOptionClient } from './usdc-option-client';
|
||||||
|
import { USDCPerpetualClient } from './usdc-perpetual-client';
|
||||||
|
import { UnifiedMarginClient } from './unified-margin-client';
|
||||||
|
import { ContractClient } from './contract-client';
|
||||||
|
|
||||||
import { signMessage } from './util/node-support';
|
import { signMessage } from './util/node-support';
|
||||||
import WsStore from './util/WsStore';
|
import WsStore from './util/WsStore';
|
||||||
@@ -32,10 +36,6 @@ import {
|
|||||||
neverGuard,
|
neverGuard,
|
||||||
getMaxTopicsPerSubscribeEvent,
|
getMaxTopicsPerSubscribeEvent,
|
||||||
} from './util';
|
} from './util';
|
||||||
import { USDCOptionClient } from './usdc-option-client';
|
|
||||||
import { USDCPerpetualClient } from './usdc-perpetual-client';
|
|
||||||
import { UnifiedMarginClient } from './unified-margin-client';
|
|
||||||
import { ContractClient } from './contract-client';
|
|
||||||
|
|
||||||
const loggerCategory = { category: 'bybit-ws' };
|
const loggerCategory = { category: 'bybit-ws' };
|
||||||
|
|
||||||
@@ -107,6 +107,9 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.prepareRESTClient();
|
this.prepareRESTClient();
|
||||||
|
|
||||||
|
// add default error handling so this doesn't crash node (if the user didn't set a handler)
|
||||||
|
this.on('error', () => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user