Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

end event never called ? #1043

Closed
adrienkohlbecker opened this issue Apr 26, 2015 · 5 comments
Closed

end event never called ? #1043

adrienkohlbecker opened this issue Apr 26, 2015 · 5 comments

Comments

@adrienkohlbecker
Copy link

Hello,

First, thanks to all contributors for this awesome project.

I'm trying to understand why the callback never gets called in the following example:

var gulp = require('gulp');
gulp.task('mytask', function(cb) {

  callSomeAsyncFunction(function() {

    gulp.src(['./somefile.js'])
      .on('end', cb); // cb never called

  });

});

Here is the output

➜  gulp mytask
[22:08:25] Using gulpfile ~/project/Gulpfile.js
[22:08:25] Starting 'mytask'...
➜ 
@adrienkohlbecker
Copy link
Author

Here is an even simpler example case, without the asynchronous function:

var gulp = require('gulp');
gulp.task('mytask', function(cb) {
    gulp.src(['./somefile.js'])
      .on('end', cb); // cb never called
  });
});

Does not work with Gulp 3.8.11 & latest 4.0 branch

@adrienkohlbecker
Copy link
Author

It does work when I add a return in the second example, but I can't do that in the asynchronous case.

@phated
Copy link
Member

phated commented Apr 26, 2015

You aren't sinking your stream. If you don't pipe a readable stream to another stream that actually reads from it, it does nothing. We sink the stream for you when you return it.

@phated phated closed this as completed Apr 26, 2015
@callumacrae
Copy link
Member

Check out readable.resume() and surrounding docs: this has bitten me before, too!

@adrienkohlbecker
Copy link
Author

Thanks both of you! I'll check it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants