gulp: Error: premature close

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!

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 31 (17 by maintainers)

Most upvoted comments

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

@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.

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

@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.

@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.

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

Error: premature close at Pumpify.onclose

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

@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.