Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Infinite loop with multiple catch()'s #28

Open
jfeldstein opened this Issue Jan 21, 2012 · 0 comments

Comments

Projects
None yet
1 participant

Should catch() not be used to catch errors after individual steps?

In my script, I have long Seq chains which perform multistep procedures, and I'd been using .catch() to respond to errors at multiple points in the chain. Turns out that when any error is encountered, the first catch in the chain is always the one that responds to it, even if execution has already passed that point. Afterwards, execution continues from that catch, often repeating chunks of the chain.

Seq = require('seq');

Seq()
.seq(function() {
  this(null, 'hi');
})
.catch(function(e){
  console.error("First catch", e);
})
.seq(function(){
  this('an error');
})
.seq(function(n){
  console.log("Should not run, proceed to catch.");
  this(null, n);
})
.catch(function(e){
  console.error("Second Catch", e);
})
.seq(function(n){
  console.log("Continued after second catch.");
  this(null, n);
})

yasuoza added a commit to yasuoza/node-seq that referenced this issue Mar 18, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment