Comcast / Comcast/hypergard

Guard against JSON parsing errors

Open
#8 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7
Forks
8
PR merge metrics
No merged PRs in 30d

Description

Currently in the onSuccess handler, there is a catch function for reading the JSON response, that tries to read the stream again (via .text()) [here](https://github.com/Comcast/hypergard/blob/master/src/hyperGard.js#L508-L521).

This causes any possible parsing error to be masked by a `TypeError: body stream already read` since we are trying to read a stream twice.

The catch function should be refactored to guard against the body already being streamed `!response.bodyUsed.`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.