Skip to content

Commit

Permalink
fix: initialise websockets provider only when enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Romsters committed Dec 19, 2023
1 parent 8f664de commit c73da98
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 5 additions & 0 deletions packages/worker/src/rpcProvider/jsonRpcProvider.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ import { JsonRpcProviderBase, JsonRpcProviderExtended, WrappedWebSocketProvider
const connectionTimeout = configService.get<number>("blockchain.rpcCallConnectionTimeout");
const connectionQuickTimeout = configService.get<number>("blockchain.rpcCallConnectionQuickTimeout");
const maxConnections = configService.get<number>("blockchain.wsMaxConnections");
const useWebSocketsForTransactions = configService.get<boolean>("blockchain.useWebSocketsForTransactions");

if (!useWebSocketsForTransactions) {
return null;
}

logger.debug(`Initializing WS RPC provider with the following URL: ${providerUrl}.`, "RpcProviderModule");

Expand Down
4 changes: 1 addition & 3 deletions packages/worker/src/rpcProvider/wrappedWebSocketProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ export class WrappedWebSocketProvider {
this.providerUrl = providerUrl;
this.connectionTimeout = connectionTimeout;
this.connectionQuickTimeout = connectionQuickTimeout;
if (!this.providerUrl) {
return;
}

for (let i = 0; i < maxConnections; i++) {
this.instances[i] = new WebSocketProviderExtended(
this.providerUrl,
Expand Down

0 comments on commit c73da98

Please sign in to comment.