Tolerate specref API failures during local dev #4167
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since #4124 was merged, all builds require an HTTP request to api.specref.org in order to resolve additional bibliographical references. This may cause issues in local dev in the case of being offline due to travel or internet hiccups, behind a proxy, etc.
This commit adds a reusable function for cases where a HTTP failure during local dev is tolerable, and uses it for the bibrefs request.
After this change, a HTTP failure on this request would look something like this, and the dev server will continue running rather than crashing with a stack trace:
AxiosError: status 403 received from https://api.specref.org/bibrefs?refs=WCAG21,WCAG20,WAI-WEBCONTENT,RFC2119,HTML,css3-values,SRGB,UAAG10,LAALS,HEARING-AID-INT,ISO-9241-3,ANSI-HFES-100-1988,ARDITI-FAYE,ARDITI-KNOBLAUCH-1994,ARDITI-KNOBLAUCH-1996,ARDITI,GITTINGS-FOZARD,pointerevents
Running
npm build
will still result in an immediate failure and stack trace; this is intentional to ensure that nothing slips by during builds for PR previews, GitHub Pages, or w3.org.