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

  • Home
  • SEARCH
  • 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 8031169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:00:20+00:00 2026-06-05T01:00:20+00:00

For some reason, every time a new socket connects to the server, my emitDraw

  • 0

For some reason, every time a new socket connects to the server, my emitDraw function stalls midway through a draw(the process.nextTick() call cycle gets broken unexpectedly). Is there anyway to keep my emitDraw function running while also accepting new connections?

io.sockets.on('connection', function(socket) {
    socket.on('drawing', function() {  
      //some code
      emitDraw(socket);
    });
});

function emitDraw(socket) {
    //some code
    process.nextTick(function(){emitDraw(socket)});
};

Thanks

  • 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-05T01:00:24+00:00Added an answer on June 5, 2026 at 1:00 am

    process.nextTick() merely helps pushing code off the current executing stack to the top of the next one. Callbacks for events fired between these two stack executions are therefore allowed execution in the next stack.

    In the current case, a normal executing stack only has emitDraw() executing and the call to process.nextTick() allows for events (notably the socket connection) to fire and execute in the next stack. Once the socket connection is fired the stack has two sets of code to execute, the callback associated with socket.on(connection) and emitDraw().

    If emitDraw() turns unresponsive, it only means that it cannot co-execute on the current stack without performance degradation.

    Since the main Node.js process runs on a single thread you cannot expect any better performance by keeping it in the same thread, except by increasing processing power. Alternatively you could fork emitDraw() to a child process so that it can execute independent of the main process.

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

Sidebar

Related Questions

For some reason, every time I attempt to install a new module using easy_install,
For some reason every time I try to count the number of rows in
well for some strange reason IE gives me and InvalidAuthenticityToken error almost every time
For some reason CodeIgniter is not connecting to my SMTP server, anyone have any
Questions: Every time i open a nib, new instances of the items in the
It seems every time I go to write a recursive function I end up
I'm developing a Rails app using the rails s WEBrick server. For some reason,
For some reason, Vim keeps using soft-tabs (tabs as spaces) everytime I'm working on
I have some tables for which I have no reason to ever update from
Question What would be a good (ideally, technical) reason to ever program some non-trivial

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.