Questions tagged [async.js]

A module with functions for working asynchronously with JavaScript that can be used both in NodeJS and in the browser.

Async is a utility module which provides straight-forward, powerful functions for working with . Although originally designed for use with , it can also be used directly in the browser.

Resources

1009 questions
9
votes
1 answer

node.js async.js nextTick vs setImmediate

I have a large node.js application that heavily uses the async.js module. I have a lot of code like this: async.series([ function(callback){ sql.update(query, callback); }, function(callback){ if (something){ …
Christie
  • 161
  • 2
  • 7
9
votes
1 answer

NodeJS, Async forEachSeries execution order

Just trying to get my head around using Async module for NodeJS. I have the following code. var a1 = [1,2,3,4,5,6,7,8]; async.forEachSeries(a1, function(n1, callback) { console.log(n1); var a2 = [10,11,12,13,14]; async.forEachSeries(a2,…
ericbae
  • 9,604
  • 25
  • 75
  • 108
7
votes
1 answer

AWS Lambda async concurrency limits

I'm working on an AWS Lambda function that currently makes hundreds of API calls but when going into production it will make hundreds of thousands. The problem is that I can't test at that scale. I'm using the async module to execute my api calls…
Julian
  • 8,808
  • 8
  • 51
  • 90
7
votes
1 answer

Insert a large csv file, 200'000 rows+, into MongoDB in NodeJS

I'm trying to parse and insert a big csv file into MongoDB but when the file extends 100'000 rows I get a bad response from the server. And the files I need to insert are usually above 200'000 rows. I've tried both bulk insert (insertMany) and…
hxmn
  • 81
  • 1
  • 4
7
votes
2 answers

Asynchronous tree traversal using async.js

I'm trying to traverse a tree of nested of items using async.js. The traversal terminates after going through just one branch. var count=0; exports.buildFamily = function(item_id, mback){ var extendedFamily={}; exports.getItembyId(item_id,…
Kinnard Hockenhull
  • 2,790
  • 5
  • 27
  • 34
7
votes
2 answers

Using nodejs async and request module

I'm trying to use async and request module together but i don't understand how the callbacks get passed. My code is var fetch = function(file, cb) { return request(file, cb); }; async.map(['file1', 'file2', 'file3'], fetch, function(err, resp,…
andrei
  • 8,252
  • 14
  • 51
  • 66
6
votes
1 answer

Provide Task type for async queue using generics

I have this right now: export type EVCb = (err:any, val?:any) => void; export type Task = (cb: EVCb) => void; export const q = async.queue((task: Task, cb) => task(cb), 2); Isn't there a way to give async.queue type information about the task using…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
6
votes
1 answer

Pass array to async library eachSeries - expects 'Dictionary<{}>'

I have the following TypeScript code: const allDescribeBlocks: Array = suman.allDescribeBlocks; async.eachSeries(allDescribeBlocks, function (block: ITestSuite, cb: Function) { //.... }, cb); this will transpile with…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
6
votes
2 answers

Node MySQL execute multiple queries the fastest possible

Which is the fastest method gets the query to MYSQL, and then comes back to output: console.log('queries finished', results)" Is there an even better method? Please explain your answer! Thanks! Method 1: var connection =…
user2278120
  • 623
  • 2
  • 9
  • 22
6
votes
1 answer

nodejs and async.waterfall with if conditions and conditional function list.

I have been working with async.waterfall and nodejs. Its working very well but now I have a question about flow. I want to use a simple if condition in async.waterfall flow. async.waterfall([ callOne, callTwo, if(condition > 0 ) { …
philipfwilson
  • 757
  • 2
  • 9
  • 21
6
votes
1 answer

Async.js - ETIMEDOUT and Callback was already called

I keep getting an ETIMEDOUT or ECONNRESET error followed by a Callback was already called error when I run index.js. At first I thought it was because I was not including return prior to calling the onEachLimitItem callback. So I included it per the…
Blexy
  • 9,573
  • 6
  • 42
  • 55
6
votes
2 answers

Async.retry executes immediately before waiting for interval

async.retry({times : 25,interval : 30000},myFunction.bind(functionData),function(err,results){ console.log("===================================") console.log("Async function finished processing") return; }) myFunction is called immediately and that…
Vikas Sharma
  • 67
  • 1
  • 2
6
votes
1 answer

Nesting node async.eachSeries

Been fighting with async module for half a day but can't get it to work properly when nesting few levels. So this works ok: var async = require('async') var myarr = ["Outer - A", "Outer - B"]; var myarr2 = ["Inner - A", "Inner - B"]; …
Timo Wallenius
  • 456
  • 5
  • 16
6
votes
1 answer

Is there an equivalent statement to 'continue' when using node.js async forEachSeries?

I am using the node.js async package, specifically forEachSeries, to make a series of http requests based on parameters drawn from an array. In the callback of each request I have some if/else statements to respond to different types of…
TankofVines
  • 1,107
  • 2
  • 14
  • 23
5
votes
2 answers

Is it possible to reject each Promise in Promise.allSettled if it takes more than 5 seconds to resolve?

I have a Promise.allSettled which i use to resolve data in the database. I have an array of Promises which I run through the Promise.allSettled, then I only use the resolved ones. Is it possible to set a timeout inside the Promise.allSettled, so…
TheStranger
  • 1,387
  • 1
  • 13
  • 35
1
2
3
67 68