<commit_before>

var Q = require("q");

task("syncfail", function() {
   fail("synchronous failure"); 
});

var http = require("http");

task("asyncfail", function() {

    waitForSleep()().then(waitForSleep).then(waitForSleep).then(waitForSleep).then(function() {
        console.log("all done, time to fail");
        fail("This is the end");
    });

    console.log("finishing sync part");
}, { async:true});


function waitForSleep() {

  return function() {
    var deferred = Q.defer();

    setTimeout(function() {
      console.log("finished timeout");
      deferred.resolve();
    });

    return deferred.promise;
  };
}<commit_msg>adding more to the jake/promises repro  (things work as expected without promises)<commit_after>

var Q = require("q");

task("syncfail", function() {
   fail("synchronous failure"); 
});


task("goodasyncfail", function() {

  waitForSleep(function() {
    waitForSleep(function() {
      waitForSleep(function() {
        console.log("all done, time to fail");
        fail("This is the end");
      });
    });
  });

  console.log("finishing sync part");
}, { async:true});


function waitForSleep(callback) {

  setTimeout(function() {
    console.log("finished timeout");
    callback();
  }, 10);
}


task("asyncfail", function() {

    waitForSleepPromise()().then(waitForSleepPromise).then(waitForSleepPromise).then(waitForSleepPromise).then(function() {
        console.log("all done, time to fail");
        fail("This is the end");
    });

    console.log("finishing sync part");
}, { async:true});


function waitForSleepPromise() {

  return function() {
    var deferred = Q.defer();

    setTimeout(function() {
      console.log("finished timeout");
      deferred.resolve();
    });

    return deferred.promise;
  };
}
{'fraction_non_alphanumeric': 0.17003367003367004, 'fraction_numerical': 0.001122334455667789, 'mean_word_length': 3.548469387755102, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3802319', 'n_tokens_mistral': 565, 'n_tokens_neox': 525, 'n_words': 113}