Skip to content

Commit 9c8837d

Browse files
jrainvilleiurimatias
authored andcommitted
fix(@embark/proxy): up max listener for proxy request manager
fix(@embark/proxy): up max listener for proxy request manager In the tests, we had warnings about max listeners reached, because the default limit is 10. So I upped the limit for the request manager and the WS connection. stoopid CI
1 parent 5531b60 commit 9c8837d

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

packages/core/engine/src/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
} from 'embark-core';
99
import { normalizeInput } from 'embark-utils';
1010
import { Logger } from 'embark-logger';
11-
1211
const EMBARK_PROCESS_NAME = 'embark';
1312

1413
export class Engine {
@@ -198,7 +197,7 @@ export class Engine {
198197
});
199198
}
200199

201-
serviceMonitor(options) {
200+
serviceMonitor(_options) {
202201
this.servicesMonitor = new ServicesMonitor({ events: this.events, logger: this.logger, plugins: this.plugins });
203202

204203
if (this.servicesMonitor) {
@@ -216,8 +215,7 @@ export class Engine {
216215
}
217216
}
218217

219-
coreComponents(options) {
220-
218+
coreComponents(_options) {
221219
// TODO: should be made into a component
222220
this.processManager = new ProcessManager({
223221
events: this.events,

packages/plugins/ganache/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
},
1616
{
1717
"path": "../../core/i18n"
18+
},
19+
{
20+
"path": "../../core/utils"
1821
}
1922
]
2023
}

packages/stack/proxy/src/proxy.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ export class Proxy {
4040
}
4141

4242
_createWeb3RequestManager(provider) {
43-
return new Web3RequestManager.Manager(provider);
43+
const manager = new Web3RequestManager.Manager(provider);
44+
// Up max listener because the default 10 limit is too low for all the events the proxy handles
45+
// Warning mostly appeared in tests
46+
manager.provider.setMaxListeners(100);
47+
return manager;
4448
}
4549

4650
async nodeReady() {
@@ -69,6 +73,9 @@ export class Proxy {
6973
if (this.isWs) {
7074
this.app.ws('/', async (conn, wsReq) => {
7175

76+
// Up max listener because the default 10 limit is too low for all the events the proxy handles
77+
// Warning mostly appeared in tests
78+
conn.setMaxListeners(100);
7279
conn.on('message', async (msg) => {
7380
try {
7481
const jsonMsg = JSON.parse(msg);
@@ -168,7 +175,7 @@ export class Proxy {
168175

169176
async handleSubscribe(clientSocket, request, response, cb) {
170177
let currentReqManager = await this.requestManager;
171-
178+
172179
// do the actual forward request to the node
173180
currentReqManager.send(request, (error, subscriptionId) => {
174181
if (error) {
@@ -205,7 +212,7 @@ export class Proxy {
205212

206213
// when the node sends subscription message, we can forward that to originating socket
207214
currentReqManager.provider.on('data', onWsData);
208-
// kill WS connetion to the node when the client connection closes
215+
// kill WS connection to the node when the client connection closes
209216
clientSocket.on('close', () => currentReqManager.provider.removeListener('data', onWsData));
210217

211218
// send a response to the original requesting inbound client socket

0 commit comments

Comments
 (0)