Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8275003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:55:25+00:00 2026-06-08T07:55:25+00:00

My node js like that but when i start this server, it meet te

  • 0

code

My node js like that but when i start this server, it meet te error :

error

and my node version is v0.6.18.
and i follow the suggestion as
possible EventEmitter memory leak detected

add req.setMaxListeners(0)
but it doesn’t work.

i attach my whole code here :

        var express = require('../node_modules/express'),
        redis = require('../node_modules/socket.io/node_modules/redis'), 
        // io = require('../node_modules/socket.io').listen(app),
        fs = require('fs');

    var app = express.createServer();
    app.use(express.bodyParser());

    var cache = redis.createClient(7010, "192.168.100.18");

    var port = 8888;

    // get html page ok
    app.get('/*', function (req, res) {
        req.setMaxListeners(0);
        res.sendfile(__dirname + '/html/' + req.params[0]);
    });

    // get js page ok
    app.get('/js/*', function (req, res){
        res.sendfile(__dirname + '/html/js/' + req.params[0]);
    });

    // get image ok
    app.get('/img/*', function (req, res){
        res.sendfile(__dirname + '/html/img/' + req.params[0]);
    });

    // login interface ok
    app.post('/login*', function(req, res, next){
        console.log("access login")
        var username = req.body.username;
        var password = req.body.password;

        if(username == null || password == null){
            console.log("username or password is nil")
            res.json({ret:false})
            return
        }

        cache.hget("margin:user:password", username, function(err, resp){
            if (err != null){
                console.log(err)
            }
            if(resp == null){
                res.json({ret:false})
                return
            }
            res.json({ret:true})
            return
        })
    });

    // upload file interface ok
    app.post('/upload*', function(req, res, next){
        console.log(req.files)
        console.log(req.body)
        fs.readFile(req.files.image.path, function(err, data){
            var unix = Math.round(+new Date()/1000);
            var imagename = unix + "." + req.files.image.type.split("/")[1]
            var newPath = __dirname + "/html/img/" + imagename;
            fs.writeFile(newPath, data, function(err){
                if(err == null){
                    res.json({ret:true, img:"http://192.168.100.188:" + port + "/html/img/" + imagename});
                    return;
                }
                res.json({ret:false});
            });
        });
    });

    app.listen(port);

my request url like localhost:8888/index.html

thanks a lot.

add error:

    (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace: 
    at Socket.<anonymous> (events.js:139:15)
    at ServerResponse.sendfile (/data/www/margintop/server/node_modules/express/lib/response.js:185:14)
    at /data/www/margintop/server/webserver/webserver.js:17:9
    at callbacks (/data/www/margintop/server/node_modules/express/lib/router/index.js:165:11)
    at param (/data/www/margintop/server/node_modules/express/lib/router/index.js:139:11)
    at pass (/data/www/margintop/server/node_modules/express/lib/router/index.js:146:5)
    at Router._dispatch (/data/www/margintop/server/node_modules/express/lib/router/index.js:173:4)
    at Object.router [as handle] (/data/www/margintop/server/node_modules/express/lib/router/index.js:33:10)
    at next (/data/www/margintop/server/node_modules/express/node_modules/connect/lib/proto.js:190:15)
    at multipart (/data/www/margintop/server/node_modules/express/node_modules/connect/lib/middleware/multipart.js:52:61)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:55:27+00:00Added an answer on June 8, 2026 at 7:55 am

    I believe this is a bug in express. Line 185 of response.js reads:

    req.socket.on('error', error);
    

    But this listener doesn’t get removed. This bug seems to have been introduced recently.

    I have added a pull request to express which fixes this.
    For a quick fix, you can add

    this.on('finish', function() { req.socket.removeListener('error', error); });
    

    after line 220 of your /data/www/margintop/server/node_modules/express/lib/response.js to make it look like this:

    res.sendfile = function(path, options, fn){
    
      // ...
    
      // socket errors
      req.socket.on('error', error);
    
      // ...
    
      this.on('finish', function() { req.socket.removeListener('error', error); });
    };
    

    Update

    My pull request has been merged, so the bug is fixed in the latest source version of express.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data object that looks like this: { 'node-16': { 'tags': ['cuda'],
I have an XML file that looks like <?xml version='1.0' encoding='UTF-8'?> <root> <node name=foo1
I have a big xml document that looks like this: <Node name=foo> <Node name=16764764625>
I have a function that looks like this class NSNode { function insertAfter(NSNode $node)
I have an xml file that has an address node that looks like <address>
I wanted to implement a Node type like written below but I want to
EDIT Solution: Visit your IP in the browser after you node server.js to kick-start
I'm playing with Remote Actors but I'm facing some difficulties. Consider this server: object
I have a long procedure I have written in node.js, but I'd like the
Grettings! I have some XML that looks like this: <Root> <SectionA> <Item id=111> <Options>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.