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.

Callback executing twice?

See original GitHub issue

Originally reported in yoshuawuyts/choo#193:

I have an effect that calls multiple effects using run-waterfall. The “sub” effects use the choo/http module to make an http request. When the requests encounter an error, they return done('Bad request'). This error message bubbles up to the parent effect, which calls done(err) itself, bubbling it up to the application event handler, which logs an uncaught error.

The problem is the uncaught error is being logged twice. Here’s a test case to demonstrate. If you switch out the http call with the setTimeout call, it only logs once. Also if you comment out the done(err) in the parent effect, it only logs once.

Am I crazy or is this unexpected behaviour?

@yoshuawuyts investigated and believes xhr is calling the callback twice. Would it be helpful to alter the test case to demonstrate it without choo? Or is this enough to diagnose?

Thanks for your help

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
naugturcommented, Jul 22, 2016

Ok, found it.

Root cause is: if you throw inside xhr callback, the code that guarantees it runs only once does not execute.

I’ll have a fix for that in minutes

0reactions
yoshuawuytscommented, Jul 22, 2016

Yay, nice! 😁

Read more comments on GitHub >

github_iconTop Results From Across the Web

Preventing callbacks from accidentally being called twice
Wrap the callback so calling it twice throws an error ... Another option is to keep track of whether the callback has already...
Read more >
Callback Functions Double Executing? Dont Forget To return
A common mistake made by all early node developers is forgetting to return after a callback. While sometimes this has no implications, there...
Read more >
Javascript callback function firing twice
I have four inputs which i would like to add a event to. The problem is that upon clicking on one of these...
Read more >
Callbacks called twice · Issue #25159 · nodejs/node
Async library checks if callback was fired twice which should not happen. The issue happens very rarely (once every 1-2 hours on one...
Read more >
Callback is called twice in a sigler event - Dash Python
In the next code ( is an example), callback is called twice in every single event. when you show the slider's id the...
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