question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve incompatible stream error

See original GitHub issue

I’m updating a script to match what is suggested via a recipe for using gulp + broswerify. The fact that it is browserify matters little, but illustrates the problem that I think needs to be addressed.

In the recipe it suggests using vinyl-source-stream. I did not initially include this dependency as I try to keep my toolchain as minimal as possible. The error output was this:

$ gulp scripts
[10:36:08] Using gulpfile ~/Dropbox/Development/github/lunch-and-learn-js/projects/gulp-yarn/gulpfile.js
[10:36:08] Starting 'clean-dist'...
[10:36:08] Finished 'clean-dist' after 5.4 ms
[10:36:08] Starting 'scripts'...
path.js:7
    throw new TypeError('Path must be a string. Received ' + inspect(path));
    ^

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.resolve (path.js:1146:7)
    at DestroyableTransform.saveFile [as _transform] (~/projects/gulp-yarn/node_modules/vinyl-fs/lib/dest/index.js:36:26)
    at DestroyableTransform.Transform._read (~/projects/gulp-yarn/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at DestroyableTransform.Transform._write (~/projects/gulp-yarn/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite (~/projects/gulp-yarn/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
    at writeOrBuffer (~/projects/gulp-yarn/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)
    at DestroyableTransform.Writable.write (~/projects/gulp-yarn/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:194:11)
    at Readable.ondata (~/projects/gulp-yarn/node_modules/readable-stream/lib/_stream_readable.js:612:20)

The above error does very, very little to tell you “hey, this not compatible with gulp’s streams”. Path must be string (I have a string path) and Received undefined are not clear enough to help me debug. The fix was simple including vinyl-source-stream and doing:

gulp.task('scripts', ['clean-dist'], () => {
  return browserify('src/scripts/main.js')
          .bundle()
          .pipe(source('app.js'))  // add this line, gulp is again happy.
          .pipe(
            gulp.dest('./dist')
          );
});

The problem is that gulp is typically superior to alternatives like grunt in that it is minimal & easy to reason about. Ideally you would get an error indicating that the file stream is incorrect, OR gulp would handle the conversion to a stream for you.

I initially added gulp-browserify, but saw that it is deprecated and encouraged the above recipe instead. Using npm modules directly is another win, so long as debugging doesn’t suffer.

Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
phatedcommented, Oct 9, 2017

vinyl-fs@latest can be dropped in to gulp 3.x and used directly. It has breaking changes and can’t be backported into gulp 3.x but you can use it as long as you use the vinyl-fs docs instead of gulp 3.x (due to those breaking changes).

An aside: I don’t believe a selling point has ever been easier debugging because streams are generally a nightmare in nodejs. I’ve been attempting to make improvements for our next major release but I don’t believe it’ll be perfect.

0reactions
benjaminapetersencommented, Oct 10, 2017

Cool, thx, might give it a spin.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Local class incompatible error when only a method has changed
I just came across "WTF" sort of error: I updated one of my classe's methods and ... Settings; local class incompatible: stream classdesc...
Read more >
How to Handle the Incompatible Types Error in Java - Rollbar
The Java incompatible types error happens when a value assigned to a variable or returned by a method is incompatible with the one...
Read more >
Live streaming error messages - YouTube Help
The Live Dashboard and Live Control Room checks for errors in the stream you're sending to YouTube. The messages are displayed next to...
Read more >
Why am I getting an Unsupported Browser error?
I'm using a supported browser, but still getting an error. One possible reason you'd get an unsupported browser message in a supported ...
Read more >
Execute Error 83: Disney+ Not Working? Here's What to Do.
Streaming on an unsupported device. Error code 39 has a quick and easy solution: make sure that you are using the Disney+ app...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found