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
This commit is contained in:
Jonathan Rainville 2020-02-17 11:48:42 -05:00 committed by Iuri Matias
parent 5531b60f10
commit 9c8837d3cd
3 changed files with 15 additions and 7 deletions

View File

@ -8,7 +8,6 @@ import {
} from 'embark-core';
import { normalizeInput } from 'embark-utils';
import { Logger } from 'embark-logger';
const EMBARK_PROCESS_NAME = 'embark';
export class Engine {
@ -198,7 +197,7 @@ export class Engine {
});
}
serviceMonitor(options) {
serviceMonitor(_options) {
this.servicesMonitor = new ServicesMonitor({ events: this.events, logger: this.logger, plugins: this.plugins });
if (this.servicesMonitor) {
@ -216,8 +215,7 @@ export class Engine {
}
}
coreComponents(options) {
coreComponents(_options) {
// TODO: should be made into a component
this.processManager = new ProcessManager({
events: this.events,

View File

@ -15,6 +15,9 @@
},
{
"path": "../../core/i18n"
},
{
"path": "../../core/utils"
}
]
}

View File

@ -40,7 +40,11 @@ export class Proxy {
}
_createWeb3RequestManager(provider) {
return new Web3RequestManager.Manager(provider);
const manager = new Web3RequestManager.Manager(provider);
// Up max listener because the default 10 limit is too low for all the events the proxy handles
// Warning mostly appeared in tests
manager.provider.setMaxListeners(100);
return manager;
}
async nodeReady() {
@ -69,6 +73,9 @@ export class Proxy {
if (this.isWs) {
this.app.ws('/', async (conn, wsReq) => {
// Up max listener because the default 10 limit is too low for all the events the proxy handles
// Warning mostly appeared in tests
conn.setMaxListeners(100);
conn.on('message', async (msg) => {
try {
const jsonMsg = JSON.parse(msg);
@ -205,7 +212,7 @@ export class Proxy {
// when the node sends subscription message, we can forward that to originating socket
currentReqManager.provider.on('data', onWsData);
// kill WS connetion to the node when the client connection closes
// kill WS connection to the node when the client connection closes
clientSocket.on('close', () => currentReqManager.provider.removeListener('data', onWsData));
// send a response to the original requesting inbound client socket