Skip to content
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

fix(ext/http): resource leak if request body is not consumed #11955

Merged
merged 2 commits into from
Sep 8, 2021

Conversation

bartlomieju
Copy link
Member

Fixes #11926

@bartlomieju
Copy link
Member Author

bartlomieju commented Sep 8, 2021

On a related note: there are two code paths in createRespondWith that can throw TypeError - I believe similar cleanup should be done in those paths. @lucacasonato what do you think?

EDIT: Disregard, those code paths cause server to raise errors anyway, so probably don't need to handle that.

// by server handler

for (const rid of Object.keys(resourcesBefore)) {
delete resourcesAfter[Number(rid)];
Copy link
Contributor

Choose a reason for hiding this comment

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

Why Number? resourcesAfter is not an array, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

TS was complaining about rid being any type 🤷

Comment on lines +303 to +306
try {
SetPrototypeDelete(httpConn.managedResources, requestRid);
core.close(requestRid);
} catch { /* pass */ }
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really understand why it's inside a swallow-everything try/catch - seems like that could hide genuine bugs - but it's a pattern that's used elsewhere in this file so 🤷

Copy link
Member Author

Choose a reason for hiding this comment

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

core.close() should only throw BadResource when the thing has already been closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hyper server leaks RequestResource objects
2 participants