storage-js
storage-js copied to clipboard
feat: always consume JSON to prevent resource leaks
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.
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.