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

Error: premature close #2086

Closed
mimoduo opened this issue Jan 4, 2018 · 31 comments
Closed

Error: premature close #2086

mimoduo opened this issue Jan 4, 2018 · 31 comments

Comments

@mimoduo
Copy link
Contributor

mimoduo commented Jan 4, 2018

Hey guys! First of all, I wanna say that gulp has been a game changer since I picked it up at the beginning. You guys make task running super duper easy and quick ~ Thank you for all your hard work!

Now for the juicy bits: My team has been running into an error related to the new alpha and I just hope there's a simple duh moment in there. I made sure to check stack overflow and other repos if the issue was encountered before. I even tried to rollback to a previous alpha build with a bit of luck in between. Here's the detailed error log and the gulpfile:

CLI version 2.0.0
Local version 4.0.0-alpha.3

https://github.com/Fastspot/Boilerplate/blob/dev/gulpfile.js#L389

[12:49:38] Starting 'modernizr'...

>> Explicitly excluding these tests:
>> hidden

Looking for Modernizr references

>> 4 matches in /Users/bryanstoner/Documents/Development/nei/css/site.css
>> csstransforms, csstransforms3d, search, touchevents

>> Ready to build using these settings:
>> load, setClasses, testProp, fnBind

Building your customized Modernizr...OK
Error: Received a non-Vinyl object in `dest()`
    at DestroyableTransform.normalize [as _transform] (/Users/bryanstoner/Documents/Development/nei/node_modules/vinyl-fs/lib/dest/prepare.js:16:17)
    at DestroyableTransform.Transform._read (/Users/bryanstoner/Documents/Development/nei/node_modules/readable-stream/lib/_stream_transform.js:182:10)
    at DestroyableTransform.Transform._write (/Users/bryanstoner/Documents/Development/nei/node_modules/readable-stream/lib/_stream_transform.js:170:83)
    at doWrite (/Users/bryanstoner/Documents/Development/nei/node_modules/readable-stream/lib/_stream_writable.js:406:64)
    at writeOrBuffer (/Users/bryanstoner/Documents/Development/nei/node_modules/readable-stream/lib/_stream_writable.js:395:5)
    at DestroyableTransform.Writable.write (/Users/bryanstoner/Documents/Development/nei/node_modules/readable-stream/lib/_stream_writable.js:322:11)
    at Pumpify.Duplexify._write (/Users/bryanstoner/Documents/Development/nei/node_modules/duplexify/index.js:201:22)
    at doWrite (/Users/bryanstoner/Documents/Development/nei/node_modules/readable-stream/lib/_stream_writable.js:406:64)
    at writeOrBuffer (/Users/bryanstoner/Documents/Development/nei/node_modules/readable-stream/lib/_stream_writable.js:395:5)
    at Pumpify.Writable.write (/Users/bryanstoner/Documents/Development/nei/node_modules/readable-stream/lib/_stream_writable.js:322:11)
    at Duplexify.ondata (/Users/bryanstoner/Documents/Development/nei/node_modules/readable-stream/lib/_stream_readable.js:612:20)
    at Duplexify.emit (events.js:159:13)
    at addChunk (/Users/bryanstoner/Documents/Development/nei/node_modules/readable-stream/lib/_stream_readable.js:284:12)
    at readableAddChunk (/Users/bryanstoner/Documents/Development/nei/node_modules/readable-stream/lib/_stream_readable.js:271:11)
    at Duplexify.Readable.push (/Users/bryanstoner/Documents/Development/nei/node_modules/readable-stream/lib/_stream_readable.js:238:10)
    at Duplexify._forward (/Users/bryanstoner/Documents/Development/nei/node_modules/duplexify/index.js:163:26)
[12:49:39] 'modernizr' errored after 1.08 s
[12:49:39] Error: premature close
    at Pumpify.onclose (/Users/bryanstoner/Documents/Development/nei/node_modules/end-of-stream/index.js:43:67)
    at Pumpify.emit (events.js:159:13)
    at Pumpify.Duplexify._destroy (/Users/bryanstoner/Documents/Development/nei/node_modules/duplexify/index.js:192:8)
    at /Users/bryanstoner/Documents/Development/nei/node_modules/duplexify/index.js:175:10
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)
[12:49:39] 'build' errored after 3.06 s
[12:49:39] 'default' errored after 3.07 s
[12:49:39] The following tasks did not complete: <series>, sprite
[12:49:39] Did you forget to signal async completion?

Any help is appreciated and as always keep up the amazing work!

@phated
Copy link
Member

phated commented Jan 4, 2018

@mimoduo Thanks! I believe I see 2 problems:

  1. gulp-modernizr relies on gulp-util which has been deprecated for a few weeks, due to causing these issues - someone opened a PR at Drop dependency on deprecated gulp-util Modernizr/gulp-modernizr#46 but the author seems unresponsive.
  2. gulp-modernizr is using a VERY old version of through2 (v0.4.0 and it's at v2.0.3 now) which I don't think is compatible with newer versions.

@phated
Copy link
Member

phated commented Jan 4, 2018

P.S. Did you know that we published the official 4.0.0 on npm? Install it with npm install gulp@next - it is mostly just alpha.3 plus an dependency upgrade to get chokidar v2!

@mimoduo
Copy link
Contributor Author

mimoduo commented Jan 4, 2018

Sweet! Thanks for the thorough response @phated!

  • Just updated gulp using gulp@next; I knew I was missing something with just npm install gulp ;)
  • I'll keeping checking up on gulp-modernizr in the mean time.

P.S. Keep rocking gulp and being awesome!

@mimoduo mimoduo closed this as completed Jan 4, 2018
@phated
Copy link
Member

phated commented Jan 4, 2018

@mimoduo cheers! I just hacked up gulp-modernizr to insert my 2 changes into your boilerplate and it works after the changes. Hopefully you're able to get the author to respond.

@phated
Copy link
Member

phated commented Jan 4, 2018

Btw, it looks like a lot of your tree has outdated vinyl code in it (v2.1.0 is latest) - I'd recommend moving away from those or getting them to upgrade:

├─┬ gulp@4.0.0
│ └─┬ vinyl-fs@3.0.1
│   ├── vinyl@2.1.0  deduped
│   └─┬ vinyl-sourcemap@1.1.0
│     └── vinyl@2.1.0  deduped
├─┬ gulp-concat-multi@1.0.1
│ ├─┬ gulp-concat@2.6.1
│ │ └── vinyl@2.1.0  deduped
│ └─┬ vinyl-fs@2.4.4
│   ├─┬ gulp-sourcemaps@1.6.0
│   │ └── vinyl@1.2.0
│   └── vinyl@1.2.0
├─┬ gulp-imagemin@4.1.0
│ └─┬ imagemin-gifsicle@5.2.0
│   └─┬ gifsicle@3.0.4
│     └─┬ bin-build@2.2.0
│       ├─┬ decompress@3.0.0
│       │ ├─┬ buffer-to-vinyl@1.1.0
│       │ │ └── vinyl@1.2.0
│       │ ├─┬ decompress-tar@3.1.0
│       │ │ └── vinyl@0.4.6
│       │ ├─┬ decompress-tarbz2@3.1.0
│       │ │ └── vinyl@0.4.6
│       │ ├─┬ decompress-targz@3.1.0
│       │ │ └── vinyl@0.4.6
│       │ ├─┬ decompress-unzip@3.4.0
│       │ │ └── vinyl@1.2.0
│       │ └─┬ vinyl-fs@2.4.4
│       │   └── vinyl@1.2.0
│       └─┬ download@4.4.3
│         ├── vinyl@1.2.0
│         └─┬ vinyl-fs@2.4.4
│           └── vinyl@1.2.0  deduped
├─┬ gulp-modernizr@1.0.0-alpha
│ ├─┬ gulp-util@2.2.20
│ │ └── vinyl@0.2.3
│ └── vinyl@2.1.0  extraneous
├─┬ gulp-svg-sprite@1.3.7
│ ├─┬ svg-sprite@1.3.7
│ │ └── vinyl@2.1.0  deduped
│ └── vinyl@2.1.0
└─┬ gulp-util@3.0.8
  └── vinyl@0.5.3

@firestar300
Copy link

Hi ! Same problem here. I installed gulp with next and always the same issue.

Error: premature close at Pumpify.onclose

@dario-baumberger
Copy link

Hei

Same Error. I tried also with gulp@next, still the same Error.

Error: premature close at Pumpify.onclose

I'm using
CLI version 2.0.0
Local version 4.0.0

@phated
Copy link
Member

phated commented Jan 9, 2018

@firestar300 @dario-baumberger as stated above, this is due to your dependencies using outdated dependencies. If you prepare a reproduction repo for me to poke at, I could tell you which dependencies are busted, but you haven't seem to have done that.

@phated
Copy link
Member

phated commented Jan 9, 2018

To anyone thinking about posting here: supply a reproduction repo so I can actually see which dependency is busted or I can't help you.

@cristianl
Copy link

cristianl commented Jan 9, 2018 via email

@phated
Copy link
Member

phated commented Jan 9, 2018

@cristianl if that's true, give me a reproduction repo so I can fix the bug in vinyl-fs 😒

@ssdatar
Copy link

ssdatar commented Jan 9, 2018

Hi @phated, here's a reproduction repo. https://github.com/ssdatar/gulp-test-repo

I am getting a similar error on Mac OS High Sierra 10.13.2. Here is my other system information.
Node: 9.3.0
npm: 5.2.0
Gulp: 4.0.0

[14:30:43] Starting 'serve'...
[14:30:43] Starting 'sass'...
[14:30:43] Finished 'sass' after 144 ms
[14:30:43] Starting 'compile'...
[14:30:43] Starting 'bundle'...
[14:30:43] 'bundle' errored after 159 ms
[14:30:43] Error: premature close
    at Pumpify.onclose (/Users/sdatar/Desktop/political-calendar/node_modules/end-of-stream/index.js:43:67)
    at Pumpify.emit (events.js:159:13)
    at Pumpify.Duplexify._destroy (/Users/sdatar/Desktop/political-calendar/node_modules/duplexify/index.js:192:8)
    at /Users/sdatar/Desktop/political-calendar/node_modules/duplexify/index.js:175:10
    at process._tickCallback (internal/process/next_tick.js:150:11)

@phated
Copy link
Member

phated commented Jan 9, 2018

@ssdatar thanks! Have you run npm outdated recently? You are depending on old and broken vinyl-source-stream and vinyl-buffer (https://github.com/ssdatar/gulp-test-repo/blob/master/package.json#L59-L60) - They need to be at 2.0.0 and 1.0.1 respectively.

@cristianl
Copy link

@phated Not sure it's worth investigating as it may be intended behavior/too much of an edge case, but here's the example: https://github.com/cristianl/testcase-vinyl-bug

Off-topic: thank you for shipping v4 and the sometimes thankless task of maintaining Gulp and the ecosystem! I'll take some time to hunt for outdated dependencies and open PRs.

@ssdatar
Copy link

ssdatar commented Jan 9, 2018

Thanks, @phated! That fixed it for me. Appreciate your help.

@phated
Copy link
Member

phated commented Jan 10, 2018

@cristianl thanks for making a reproduction case for me. I was able to boil it down to the simplest case in our dependencies. I'm hoping to hear back on it soon.

@dario-baumberger
Copy link

@phated Thanks for your reply.
I've updated all modules, and checked permissions.

Here's a reproduction repo: https://github.com/dario-baumberger/test-gulp
There are only the dependencies wich are required for the failing task.

@phated
Copy link
Member

phated commented Jan 10, 2018

@dario-baumberger your modules are extremely out-of-date and seem to be abandoned. They are using the deprecated gulp-util module which won't work with gulp 4. I suggest you find new plugins to use.

@gauntface
Copy link

The branch here seems to hit this error if you run gulp build a few times (but it's intermittent)

https://github.com/google/web-starter-kit/tree/wsk-next

@phated
Copy link
Member

phated commented Jan 15, 2018

Hey all, I just published a fix to async-done (v1.2.4) that will allow you to see the errors from your tasks, instead of "premature close". Please make sure to update your dependencies (it might not happen automatically because of the terribleness of npm's package-lock files).

cc @gauntface

@phated
Copy link
Member

phated commented Jan 15, 2018

@cristianl Thanks for the reproduction case, it really helped me dig into this problem and get it solved!

@rogperez
Copy link

I removed my dependency on gulp-add-src and I no longer got the error.

@phated
Copy link
Member

phated commented Jan 16, 2018

@rogperez with gulp 4, there's no need to use gulp-add-src - I spent a lot of time figuring out how to make gulp.src a Readable and Transform stream.

@rogperez
Copy link

Ah great! @phated

@nathancarter
Copy link

I still get this error with the minimal example shown in this gist and all fully updated versions of everything (as far as I can tell). That includes just these:

  • gulp 4.0.0
  • gulp-uglify 3.0.1
  • pump 3.0.0

Error:

$ gulp
[11:53:42] Using gulpfile /my/example/gulpfile.js
[11:53:42] Starting 'default'...
[11:53:42] 'default' errored after 37 ms
[11:53:42] Error: premature close
    at Pumpify.onclose (/my/example/node_modules/end-of-stream/index.js:47:67)
    at emitNone (events.js:110:20)
    at Pumpify.emit (events.js:207:7)
    at Pumpify.Duplexify._destroy (/my/example/node_modules/duplexify/index.js:199:8)
    at /my/example/node_modules/duplexify/index.js:182:10
    at _combinedTickCallback (internal/process/next_tick.js:95:7)
    at process._tickDomainCallback (internal/process/next_tick.js:198:9)

@nathancarter
Copy link

@phated Would you prefer I open a new issue rather than comment on this closed one? It seems like the same issue to me, but I can start a new one if you prefer.

@phated
Copy link
Member

phated commented Nov 5, 2018

You can't use pump without a callback. I think you might want to switch to the readable-stream module and use the pipeline method. The nodejs team took my patch but pump wouldn't.

@nathancarter
Copy link

I googled around a bit, but my apologies for not being able to figure out what you meant by this. Do you by any chance have a link to the techniques you're describing here? Sorry for my lack of gulp expertise.

@phated
Copy link
Member

phated commented Nov 6, 2018

@nathancarter Sorry, it's in Node's core docs at https://nodejs.org/api/stream.html#stream_stream_pipeline_streams_callback - it's easier to recommend readable-stream because that supports older versions of node. It has the same API as pump (except that it actually returns a proper stream which pump doesn't)

@nathancarter
Copy link

Got it. Just a plain old chain of pipe()s worked for me. Thanks!

@phated
Copy link
Member

phated commented Nov 7, 2018

Glad you solved it. We'll hopefully be writing up a document at some point explaining why plain pipe is bad 😛

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

9 participants