question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Receiving "Too much pending tasks" error when we use the library to send multiple concurrent messages from a node express app

See original GitHub issue

Receiving “Too much pending tasks” error when we use the library to send messages from a node express app. The issue occurs when we make multiple concurrent calls to await client.send(eventData)

To Reproduce Make multiple concurrent calls to await client.send(eventData)

Package-name: azure-event-hubs Package-version: 0.2.5 node.js version: 10.0.0 OS name and version: Azure App Service ,node-express app, Windows

Error Call stack

[
    {
        "outerId": "0",
        "message": "Too much pending tasks",
        "severityLevel": "Error",
        "parsedStack": [
            {
                "assembly": "at AppInsightsAsyncCorrelatedErrorWrapper.ZoneAwareError (D:\\home\\site\\wwwroot\\node_modules\\zone.js\\dist\\zone-node.js:811:33)",
                "method": "AppInsightsAsyncCorrelatedErrorWrapper.ZoneAwareError",
                "level": 0,
                "line": 811,
                "fileName": "D:\\home\\site\\wwwroot\\node_modules\\zone.js\\dist\\zone-node.js"
            },
            {
                "assembly": "at new AppInsightsAsyncCorrelatedErrorWrapper (D:\\home\\site\\wwwroot\\node_modules\\applicationinsights\\out\\AutoCollection\\CorrelationContextManager.js:193:18)",
                "method": "new AppInsightsAsyncCorrelatedErrorWrapper",
                "level": 1,
                "line": 193,
                "fileName": "D:\\home\\site\\wwwroot\\node_modules\\applicationinsights\\out\\AutoCollection\\CorrelationContextManager.js"
            },
            {
                "assembly": "at AsyncLock.acquire (D:\\home\\site\\wwwroot\\node_modules\\async-lock\\lib\\index.js:141:15)",
                "method": "AsyncLock.acquire",
                "level": 2,
                "line": 141,
                "fileName": "D:\\home\\site\\wwwroot\\node_modules\\async-lock\\lib\\index.js"
            },
            {
                "assembly": "at EventHubSender.send (D:\\home\\site\\wwwroot\\node_modules\\azure-event-hubs\\dist\\lib\\eventHubSender.js:75:49)",
                "method": "EventHubSender.send",
                "level": 3,
                "line": 75,
                "fileName": "D:\\home\\site\\wwwroot\\node_modules\\azure-event-hubs\\dist\\lib\\eventHubSender.js"
            },
            {
                "assembly": "at EventHubClient.send (D:\\home\\site\\wwwroot\\node_modules\\azure-event-hubs\\dist\\lib\\eventHubClient.js:74:29)",
                "method": "EventHubClient.send",
                "level": 4,
                "line": 74,
                "fileName": "D:\\home\\site\\wwwroot\\node_modules\\azure-event-hubs\\dist\\lib\\eventHubClient.js"
            },            
            {
                "assembly": "at Layer.handle [as handle_request] (D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\layer.js:95:5)",
                "method": "Layer.handle [as handle_request]",
                "level": 8,
                "line": 95,
                "fileName": "D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\layer.js"
            },
            {
                "assembly": "at next (D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\route.js:137:13)",
                "method": "next",
                "level": 9,
                "line": 137,
                "fileName": "D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\route.js"
            },
            {
                "assembly": "at Route.dispatch (D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\route.js:112:3)",
                "method": "Route.dispatch",
                "level": 10,
                "line": 112,
                "fileName": "D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\route.js"
            },
            {
                "assembly": "at Layer.handle [as handle_request] (D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\layer.js:95:5)",
                "method": "Layer.handle [as handle_request]",
                "level": 11,
                "line": 95,
                "fileName": "D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\layer.js"
            },
            {
                "assembly": "at D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\index.js:281:22",
                "method": "<no_method>",
                "level": 12,
                "line": 281,
                "fileName": "D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\index.js"
            },
            {
                "assembly": "at param (D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\index.js:354:14)",
                "method": "param",
                "level": 13,
                "line": 354,
                "fileName": "D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\index.js"
            },
            {
                "assembly": "at param (D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\index.js:365:14)",
                "method": "param",
                "level": 14,
                "line": 365,
                "fileName": "D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\index.js"
            },
            {
                "assembly": "at Function.process_params (D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\index.js:410:3)",
                "method": "Function.process_params",
                "level": 15,
                "line": 410,
                "fileName": "D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\index.js"
            },
            {
                "assembly": "at next (D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\index.js:275:10)",
                "method": "next",
                "level": 16,
                "line": 275,
                "fileName": "D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\index.js"
            },
            {
                "assembly": "at Function.handle (D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\index.js:174:3)",
                "method": "Function.handle",
                "level": 17,
                "line": 174,
                "fileName": "D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\index.js"
            },
            {
                "assembly": "at router (D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\index.js:47:12)",
                "method": "router",
                "level": 18,
                "line": 47,
                "fileName": "D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\index.js"
            },
            {
                "assembly": "at Layer.handle [as handle_request] (D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\layer.js:95:5)",
                "method": "Layer.handle [as handle_request]",
                "level": 19,
                "line": 95,
                "fileName": "D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\layer.js"
            },
            {
                "assembly": "at trim_prefix (D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\index.js:317:13)",
                "method": "trim_prefix",
                "level": 20,
                "line": 317,
                "fileName": "D:\\home\\site\\wwwroot\\node_modules\\express\\lib\\router\\index.js"
            }
        ],
        "type": "Error",
        "id": "0"
    }
]

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
ramya-rao-acommented, Mar 7, 2019

@amarzavery

All of them try to establish a sender link if there isn’t one. There is an async lock on that

I believe we can update our library such that if a sender link is in the process of being created, then future send requests waits for the sender link to be created instead of requesting new sender links.

Is there any reason you can think of where we cannot do this?

0reactions
richardpark-msftcommented, Mar 24, 2020

Just tried this out - the API surface has changed so I ended up sending 2000 individual batches with one message apiece, simultaneously. No issue.

Also, traced down the code and we are indeed using AwaitableSender now.

Closing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to run many parallel HTTP requests using Node.js
Step 1: Create a NodeJS application and install the required Express.js module. mkdir Project && cd Project npm init -y npm i express....
Read more >
Node.js multithreading: Worker threads and why they matter
But concurrency can be a very hard problem to solve. Having many threads accessing the same memory can produce race conditions that are...
Read more >
Don't Block the Event Loop (or the Worker Pool) - Node.js
Because Node. js handles many clients with few threads, if a thread blocks handling one client's request, then pending client requests may not...
Read more >
Top 10 Most Common Node.js Developer Mistakes - Toptal
For brevity, we used simpler examples here, but reality is often worse. Mistake #4: Expecting Callbacks to Run Synchronously. Asynchronous programming with ...
Read more >
node and Error: EMFILE, too many open files - Stack Overflow
Even stranger, I still receive the same error after I've increased the number of file descriptors. Second question: After a number of searches...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found