-
-
Notifications
You must be signed in to change notification settings - Fork 956
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
Don't use instanceof stream.Readable, it's an interface #1424
Conversation
It's not and I can prove you wrong:
Wow. Because it is used in other places doesn't mean it's correct [for this one].
This is not a Got issue.
Please raise an issue in the |
Right, JS doesn't have interfaces, but, from the very first line of the Node.js docs:
In other words, extending
Yet in this case it's pretty clearly causing issues with legacy
|
By the way, your tone was kind of unnecessarily terse and rude there. I understand that you might have to deal with a lot of inexperienced people in issues, but you kind of come off as condescending. :( |
Many people come to Got and report issues related to other projects because the integration simply does not work. It doesn't mean that it is actually Got's fault. In most cases it's either Node.js' or the other project's. I have proposed a solution, so the issue is solved on Got's side. Here's a deeper explaination.
I haven't offended you in any way. I haven't said a thing you've done incorrectly. I just stated the facts. If that's how you feel, I'm sorry.
That is NOT the point. Even very experienced people open Got issues just to report incompatibility with other projects.
Well, it may seem so (especially when an issue is closed almost right away) but that's definitely not true. See:
Exactly.
No, it means exactly what it says. An abstract interface is just a bare look. The
Yep, there is. Backwards compatibility. This is the current implementation from March 2017: isStream.readable = stream =>
isStream(stream) &&
stream.readable !== false &&
typeof stream._read === 'function' &&
typeof stream._readableState === 'object'; And this is the one from January 2015: isStream.readable = function (stream) {
return isStream(stream) && typeof stream._read == 'function' && typeof stream._readableState == 'object';
}; It hasn't changed much. But it's 2020, not 2015 nor 2017.
While
Which you can easily mimic this behavior.
I wouldn't expect this to not cause issues. Node.js docs recommend this:
And as I've already mentioned it also discourages |
@szmarczak The fact of the matter is, there are legitimate cases where a stream might not want to extend Readable, and got should be able to handle it. I'm not sure what issues arise from being more lax on stream support in order to support these cases. I would be more than happy to revise this in order to check more properties than just From the cursory look I took the other night at how |
Per Node.js docs there are no such legitimate cases.
The current implementation is totally valid. No need to loose the logic.
I strongly disagree. It's 2020 and the standards aren't the same as in 2015.
The zip specification is one factor. There are plenty others that always will require some work to do. This discussion doesn't seem to have an end, although I have already proposed a solution. Locking. |
stream.Readable
doesn't need to be extended from, it's just an interface that readable streams implement. I replacedbody instanceof stream.Readable
withis.nodeStream()
because that's the check that was used in other places of the code.Specifically, I was trying to use archiver with chrome-webstore-upload which recently started using
got
(in version 4.0) which broke my publish CI script because of this. Archiver doesn't actually extendstream.Readable
, it only implements it, which caused the issue.Checklist