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

feat: always consume JSON to prevent resource leaks #174

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mansueli
Copy link
Member

What kind of change does this PR introduce?

We get resource leaks because in the _handleRequest function, a fetch request is made and its response is thrown if it's not ok.

What is the current behavior?

If the noResolveJson option is not set, it returns the JSON body of the response (return result.json()). But in case an error occurs (the response is not ok) or the noResolveJson option is set, the function just throws or returns the response without consuming its body.

What is the new behavior?

It will always consume the response to prevent leaks.

Additional context

Add any other context or screenshots.

@mansueli mansueli changed the title feat: always consume to prevent resource leaks feat: always consume JSON to prevent resource leaks Jul 25, 2023
@mansueli mansueli requested a review from phamhieu July 26, 2023 14:16
@soedirgo
Copy link
Member

Do we have evidence that there were leaks and that this prevents the leaks? I would've expected the response to be GC'd once there's no more reference to it.

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.

2 participants