8000 feat: add ignore method to IncomingMessage by kyrylo-hrechykhin · Pull Request #35767 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: add ignore method to IncomingMessage #35767

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

Conversation

kyrylo-hrechykhin
Copy link
Contributor
@kyrylo-hrechykhin kyrylo-hrechykhin commented Sep 22, 2022

Description of Change

That method makes possible to indicate that response is ignored, and all data chunks should be dropped. Otherwise, response data should be read. If response data is not read and is not ignored, memory leak will happen per each net.request call in browser process.

Fixes #34158
CC: @VerteDinde

Checklist

Release Notes

Notes: Method ignore() is added to IncomingMessage in order to prevent memory leaks in browser process when data is not read.

That method makes possible to indicate that reponse is ignored and all data chunks should be dropped.
@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Sep 22, 2022
@kyrylo-hrechykhin kyrylo-hrechykhin marked this pull request as ready for review September 22, 2022 14:41
@VerteDinde VerteDinde added semver/patch backwards-compatible bug fixes target/19-x-y target/21-x-y PR should also be added to the "21-x-y" branch. and removed merged/20-x-y labels Sep 22, 2022
@VerteDinde
Copy link
Member

@kyrylo-hrechykhin Thanks for the PR! Since this is a new method, would it be possible to add a test or two for it, just to make sure we can catch it in the future if it regresses?

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Sep 23, 2022
@MarshallOfSound MarshallOfSound added semver/minor backwards-compatible functionality and removed semver/patch backwards-compatible bug fixes labels Sep 23, 2022
@MarshallOfSound MarshallOfSound changed the title fix: add ignore method to IncomingMessage feat: add ignore method to IncomingMessage Sep 23, 2022
Copy link
Member
@codebytere codebytere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if my understanding is correct, the changes in #25531 made it such that memory leaks now happen more easily/by default unless the user utilizes the API added in this PR?

If that's the case, I'd really like to try to see if there's an alternate solution that allows for us to fix this problem without creating a new, potentially unintuitive API which users must use to prevent the leaks. It's not that i'm against the API design per se, but rather I think that adding new API to address what is arguably a bug is probably not the most effective solution.

Indicates that response is ignored. Cancels all chunks of data from being downloaded.

**Note:** Please make sure you call this method if response data is not read.
Otherwise it will lead to memory leaks in browser process ([#34158](https://github.com/electron/electron/issues/34158)).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to link to bugs in our documentation I wouldn't say.

@kyrylo-hrechykhin
Copy link 8000
Contributor Author

if my understanding is correct, the changes in #25531 made it such that memory leaks now happen more easily/by default unless the user utilizes the API added in this PR?

If that's the case, I'd really like to try to see if there's an alternate solution that allows for us to fix this problem without creating a new, potentially unintuitive API which users must use to prevent the leaks. It's not that i'm against the API design per se, but rather I think that adding new API to address what is arguably a bug is probably not the most effective solution.

Thanks for the comment. Absolutely agree that it is better to fix it properly rather than modify API in order to avoid memory leaks. I did not find solution that will be better in this case when I created this PR. I will check if it is possible to pin body chunk getter on first resume callback call. It will indicate that response is being read.

@nornagon
Copy link
Contributor

Could we use a FinalizationRegistry to watch for GC? Or hook the destructor on the C++ side?

@jkleinsc jkleinsc added the target/22-x-y PR should also be added to the "22-x-y" branch. label Sep 28, 2022
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Oct 17, 2022
@jkleinsc jkleinsc added the target/23-x-y PR should also be added to the "23-x-y" branch. label Nov 30, 2022
@jkleinsc jkleinsc added the target/24-x-y PR should also be added to the "24-x-y" branch. label Feb 9, 2023
@jkleinsc jkleinsc added target/25-x-y PR should also be added to the "25-x-y" branch. and removed target/21-x-y PR should also be added to the "21-x-y" branch. labels Apr 6, 2023
@github-actions github-actions bot added the target/26-x-y PR should also be added to the "26-x-y" branch. label May 31, 2023
@github-actions github-actions bot added the target/27-x-y PR should also be added to the "27-x-y" branch. label Aug 16, 2023
@miniak miniak removed target/23-x-y PR should also be added to the "23-x-y" branch. target/22-x-y PR should also be added to the "22-x-y" branch. target/24-x-y PR should also be added to the "24-x-y" branch. labels Oct 9, 2023
@github-actions github-actions bot added the target/28-x-y PR should also be added to the "28-x-y" branch. label Oct 11, 2023
@github-actions github-actions bot added the target/29-x-y PR should also be added to the "29-x-y" branch. label Dec 6, 2023
@codebytere
Copy link
Member

@kyrylo-hrechykhin would you still like to see this move forward?

@github-actions github-actions bot added the target/30-x-y PR should also be added to the "30-x-y" branch. label Feb 21, 2024
@miniak miniak removed target/25-x-y PR should also be added to the "25-x-y" branch. target/26-x-y PR should also be added to the "26-x-y" branch. target/27-x-y PR should also be added to the "27-x-y" branch. labels Apr 15, 2024
@github-actions github-actions bot added the target/31-x-y PR should also be added to the "31-x-y" branch. label Apr 17, 2024
@github-actions github-actions bot added the target/32-x-y PR should also be added to the "32-x-y" branch. label Jun 12, 2024
@github-actions github-actions bot added the target/33-x-y PR should also be added to the "33-x-y" branch. label Aug 20, 2024
@github-actions github-actions bot added the target/34-x-y PR should also be added to the "34-x-y" branch. label Oct 15, 2024
@samuelmaddock
Copy link
Member

I'm closing this PR due to staleness. Please feel free to reopen if there's renewed interest in continuing this work! 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-review/requested 🗳 semver/minor backwards-compatible functionality target/28-x-y PR should also be added to the "28-x-y" branch. target/29-x-y PR should also be added to the "29-x-y" branch. target/30-x-y PR should also be added to the "30-x-y" branch. target/31-x-y PR should also be added to the "31-x-y" branch. target/32-x-y PR should also be added to the "32-x-y" branch. target/33-x-y PR should also be added to the "33-x-y" branch. target/34-x-y PR should also be added to the "34-x-y" branch. wip ⚒
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: ClientRequest created by net.request is not destroyed if response data is not read
8 participants
0