MaxListenersExceededWarning

Any idea why this is logged?

(node:17983) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 connect listeners added. Use emitter.setMaxListeners() to increase limit

I’m on 2.8.4

Is it on the client or server?

It’s logged on the server

It is a node.js warning that happens when you have multiple handlers being added to the same event. Anything special in your parse server setup? Maybe the way you are mounting parse server on the express.js application? or maybe cloud code or live query?

What is a handler?

Here’s my index.js file:

var express = require(‘express’);
var ParseServer = require(‘parse-server’).ParseServer;
var ParseDashboard = require(‘parse-dashboard’);
var allowInsecureHTTP = true;
var path = require(‘path’);
var S3Adapter = require(‘parse-server’).S3Adapter;
var AWS = require(“aws-sdk”);

var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI;

if (!databaseUri) {
console.log(‘DATABASE_URI not specified, falling back to localhost.’);
}

process.env.NODE_TLS_REJECT_UNAUTHORIZED = ‘0’;

//Set Digital Ocean Spaces EndPoint
const spacesEndpoint = new AWS.Endpoint(’’);
//Define S3 options
var s3Options = {
bucket: ‘’,
baseUrl: ‘’,
region: ‘fra1’,
directAccess: true,
globalCacheControl: “public, max-age=31536000”,
s3overrides: {
accessKeyId: ‘’,
secretAccessKey: ‘’,
endpoint: spacesEndpoint
}
};

var s3Adapter = new S3Adapter(s3Options);

var api = new ParseServer({
databaseURI: databaseUri,
cloud: ‘cloud-code-repository/main.js’,
appId: process.env.APP_ID,
allowClientClassCreation: false,
masterKey: process.env.MASTER_KEY,
fileKey: ‘’,
filesAdapter: s3Adapter,
serverURL: process.env.SERVER_URL || ‘http://ip:1337/parse’,
logLevel: ‘notice’,
expireInactiveSessions: false,

push: {
ios: {
pfx: path.join(__dirname, ‘./certificates/PushCertificate.p12’),
topic: ‘’,
production: true
}
},

verifyUserEmails: false,

publicServerURL: ‘http://ip:1337/parse’,

// The email adapter
emailAdapter: {
module: ‘@parse/simple-mailgun-adapter’,
options: {
// The address that your emails come from
fromAddress: ‘[email protected]’,
// Your domain from mailgun.com
domain: ‘’,
// Your API key from mailgun.com
apiKey: ‘’,
}
}
});

var app = express();

// Serve static assets from the /public folder
app.use(’/public’, express.static(path.join(__dirname, ‘/public’)));

// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || ‘/parse’;
app.use(mountPath, api);

// Parse Server plays nicely with the rest of your web routes
app.get(’/’, function(req, res) {
res.status(200).send(‘Make sure to star the parse-server repo on GitHub!’);
});

app.get("/recordingFile/:name/", function(request, response) {
response.sendFile(path.join(__dirname, “…/recordingFiles/”) + request.params.name, (error) => {
if (error)
response.status(400).send({ message: “Error” });
});
});

var port = process.env.PORT || 1337;
var httpServer = require(‘http’).createServer(app);
httpServer.listen(port, function() {
console.log('parse-server-example running on port ’ + port + ‘.’);
});

// Set up parse dashboard

var dashboardConfig = {
“allowInsecureHTTP”: true,
“apps”: [
{
“serverURL”: “http://ip:1337/parse”,
“appId”: “”,
“masterKey”: “”,
“appName”: " “,
“production”: true
}
],“users”: [
{
“user”:”",
“pass”:""
}
]
};

var dashboard = new ParseDashboard(dashboardConfig, {
allowInsecureHTTP: dashboardConfig.allowInsecureHTTP
});
var dashApp = express();

// make the Parse Dashboard available at /dashboard
dashApp.use(’/dashboard’, dashboard);

// Parse Server plays nicely with the rest of your web routes
dashApp.get(’/’, function(req, res) {
res.status(200).send(‘Parse Dashboard App’);
});

var httpServerDash = require(‘http’).createServer(dashApp);
httpServerDash.listen(4040, function() {
console.log(‘dashboard-server running on port 4040.’);
});

It is probably something in your cloud code. Something like the following if called multiple times (I think the default node setting for this is 10) could fire this warning:

Parse.LiveQuery.on('error', (error) => {
  console.log(error);
});

I found something but not sure if it’s related: https://github.com/parse-community/parse-server/pull/7083

Unfortunately no. I don’t have LiveQuery enabled.

since you mentioned that you are on version 2.8, this is an old version; an update may fix it :slight_smile:

1 Like