-
-
Notifications
You must be signed in to change notification settings - Fork 133
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
cloneIncomingMessage does not handle headers
field in Node.js v16
#212
Comments
Sorry. The proposed test improvements don't seem to make sense. It seems to pass on Node.js v12 but not on the Node.js v16 or higher. |
The issue here seems to be related to the fact that |
The test seems to expect to clone the headers feild. |
Hey, folks. Thanks for elaborating on this. I'll get to reproduce this in Node 16 when I have a minute. Overall, the incoming message cloning is perhaps the most unstable part of this library. I couldn't find any good resources on how to do that, and the only approach I found was to split Cloning Also, the only reason we need to clone the incoming message is to be able to read it on the library's side and don't block the reading on the consumer's side. If we can't find a reliable way to clone incoming message, the last resort would be to drop the response body from the |
The https://github.com/nodejs/node/blob/master/lib/_http_incoming.js#L107 So currently implementation doesn't clone I try to clone the However, it is a bit scary code. const stream = message.pipe(new PassThrough())
const proto = {}
for (const prop of [
...Object.getOwnPropertyNames(IncomingMessage.prototype),
...Object.getOwnPropertySymbols(IncomingMessage.prototype),
]) {
Object.defineProperty(proto, prop, {
...Object.getOwnPropertyDescriptor(IncomingMessage.prototype, prop),
});
}
for (const prop of [
...Object.getOwnPropertyNames(PassThrough.prototype),
...Object.getOwnPropertySymbols(PassThrough.prototype),
]) {
Object.defineProperty(proto, prop, {
...Object.getOwnPropertyDescriptor(PassThrough.prototype, prop),
});
}
Object.setPrototypeOf(stream, proto); |
That's a good observation, @hrsh7th. Then we can extract property descriptors from
Okay, that seems to be how we're doing it now:
I wonder why |
The current implementation will clone properties defined in So I think we should add it. I'll make PR soon. |
I've submitted the PR. I'm not an English speaker so I'm sorry. I'll talk about this via actual codes. |
Awesome find. I tried cloning it with the clone npm library and it worked,
minus successfully adding the IS_CLONE property which broke a few other
things.
…On Sat, Feb 26, 2022 at 5:25 AM hrsh7th ***@***.***> wrote:
The current implementation will clone properties defined in instance but
not clone properties defined in prototype.
So I think we should add it. I'll make PR soon.
—
Reply to this email directly, view it on GitHub
<#212 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAFACBL2KTG3PZ5BFEN7ZTU5DIFJANCNFSM5PKKVPVQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID:
***@***.***>
|
Oh. If we just want to clone (without using PassThrough), it's can use |
#195 seems related Also nodejs/node#36550 could have valuable background info related to the lazy |
🎉 This issue has been resolved in version 0.13.6 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I met the problem described in the title. I've investigated it and found the cause.
The
src/interceptors/ClientRequest/utils/cloneIncomingMessage
is not properly.But I don't know how to fix it properly. I'm planning to consider it but first I share it via this issue.
--- Edit
I removed the meaningless tests.
The text was updated successfully, but these errors were encountered: