Skip to content

Commit

Permalink
fix(@embark/proxy): up max listener for proxy request manager
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jrainville authored and iurimatias committed Feb 17, 2020
1 parent 5531b60 commit 9c8837d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 2 additions & 4 deletions packages/core/engine/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand All @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions packages/plugins/ganache/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
},
{
"path": "../../core/i18n"
},
{
"path": "../../core/utils"
}
]
}
13 changes: 10 additions & 3 deletions packages/stack/proxy/src/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -168,7 +175,7 @@ export class Proxy {

async handleSubscribe(clientSocket, request, response, cb) {
let currentReqManager = await this.requestManager;

// do the actual forward request to the node
currentReqManager.send(request, (error, subscriptionId) => {
if (error) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9c8837d

Please sign in to comment.