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 8244521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:52:45+00:00 2026-06-07T21:52:45+00:00

When using async library for flow control, specifically async.forEach how do you properly perform

  • 0

When using async library for flow control, specifically async.forEach how do you properly perform a callback in case when you need to skip a specific item.

Example:

async.forEach(bigCollection, function(item, callback) {

    if(skipThis) {
        return callback();
        // OR BELLOW IS BETTER??
        //return process.nextTick(callback);
    }

    db.query(query, callback);

}, callback);

In case that I don’t use process.nextTick(callback) do I risk running into stack overflow if the bigCollection is too big? And in case that I do use process.nextTick(callback) do I anyhow sabotage my code?

I have got into habit of doing it the process.nextTick(callback) way, however I am not so sure it’s a good practice to do so.

  • 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-07T21:52:47+00:00Added an answer on June 7, 2026 at 9:52 pm

    I would say that without nextTick it’s ok.

    async.forEach(bigCollection, function(item, callback) {
        if(skipThis) {
            return callback();
        }
        db.query(query, callback);
    }, callback);
    

    If bigCollection is too big, then you will get the overflow before you come into the loop.

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

Sidebar

Related Questions

I am using some third party library to connect to a server via async
I am using the node.js async package, specifically forEachSeries, to make a series of
I am using the Async CTP library for Windows Phone. Does anyone know how
I am using the async library ( https://github.com/caolan/async ) on node trying to execute
I am using Perl library HTTP::Async as follows: use strict; use warnings; use HTTP::Async;
I'm using twitter-async library to interact with twitter api. However, the memory limit keeps
I'm using the twitter-async library to do some oauth calls to twitter but ultimately,
I have a library that serves using events data came in from async tcp
I'm using Sonatype async-http-client java library to make a websocket call to a WebServer
Being writing a completely async library to access a remote service (using Play2.0), I'm

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.