-
Notifications
You must be signed in to change notification settings - Fork 88
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
The _stream_wrap module is deprecated #41
Comments
Yes, good to keep track of this. Some context: this is used in https://github.com/httptoolkit/httpolyglot to ensure we can work around certain node issues. I've been talking to the node team about this already, there's further context in nodejs/node#34296 if you're interested. The conclusion is that we shouldn't actually need If the deprecation is a big problem in the meantime, we could do an inline require instead in httppolyglot, so that it only appears when the first HTTP/2 request appears. I'm inclined not to by default though, just to keep things simple, unless it does start to cause problems. |
That's a brilliant follow-up, thanks Tim! Sure it doesn't bother that much and seems like keeping the warning makes more sense than getting rid of it. I'll close the issue for now because it's not actionable at the moment, let's get back to it in a few years. |
https://github.com/httptoolkit/httpolyglot/blob/master/src/index.ts#L139 socket._handle.isStreamBase = false
h2Server.emit('connection', socket) Can get rid of warning forced to use JSStreamSocket from inside Http2 |
Hi @YuraDev. Good idea! I just gave this a quick test though, and using that in the Mockttp tests results in If you're interested in investigating further though and trying to find a fix for this, I would definitely appreciate that. You test any changes by:
If you can find a change that avoids this deprecation and still passes those tests, I would love to hear about it! |
_handle missing Http2Stream if (socket._handle) {
socket._handle.isStreamBase = false
} |
Hack import * as tls from 'tls'
import * as stream from 'stream'
const JSStreamSocket = (new tls.TLSSocket(new stream.PassThrough()))._handle._parentWrap.constructor; |
const JSStreamSocket = (new tls.TLSSocket(new stream.PassThrough()))._handle._parentWrap.constructor; 😆 very clever! I am a bit cautious about some of these Node.js internal tricks. I don't want to do anything too clever and replace a deprecation warning with a dependency on fields that may disappear and break things completely at any time though. At least That 2nd patch does seem to work reliably though - it's easy to write so that it doesn't break if internals change, and after digging through the Node code I'm reasonably confident there's no side effects here. There is however a risk that the internal logic for this will change in future, stopping this working ( We could detect that easily enough (check whether a real stream has an I'm also going to do some debugging in Node.js itself today, and see if I can find the underlying cause of these HTTP/2 issues, so we don't need the stream wrapper at all in future. Either way, this looks promising, thanks for the suggestion! |
Now fixed in Mockttp v2.5.0. The patch above is used to avoid the deprecation warning for all Node releases > v12. For v12 and older I've also opened a PR to fix the underlying issue in Node itself in nodejs/node#41185. That's approved by a few Node maintainers now, but not yet merged. Hopefully that'll make it in for Node v18 and potentially get backported as well, which will allow us to remove the patch here entirely, and should help a fair few other HTTP/2 use cases too. |
On node 12.13.0 I see this warning:
It can be a low priority, of course, but it's nice to keep track of it.
The text was updated successfully, but these errors were encountered: