-
Notifications
You must be signed in to change notification settings - Fork 0
π‘οΈ Sentinel: [Medium] Add explicit timeouts to all external fetch calls #24
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,6 +85,7 @@ export async function getNetworkStatus(): Promise<NetworkStatus> { | |
| headers: { | ||
| Accept: "application/json", | ||
| }, | ||
| signal: AbortSignal.timeout(NODE_PROBE_TIMEOUT_MS), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On Useful? React with πΒ / π. |
||
| }); | ||
|
|
||
| if (!response.ok) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π‘ Medium
https://github.com/felirami/hypersnaporg/blob/96c282ec0689e64f9bf8d36a2860a19f7331d88d/scripts/sync-sources.mjs#L29
When
optional: trueis passed and the request times out,AbortSignal.timeout()causesfetchto reject with aTimeoutErrorbefore the response status is checked. This bypasses the graceful handling of 404/409 on lines 39-41, causing the entire script to crash even for optional resources likehyper.mdorSUMMARY.mdwhen GitHub is slow.Consider catching
AbortErrorand returningnull(or the appropriate empty value) whenoptionalis true, so timeouts don't crash the script.π Reply "fix it for me" or copy this AI Prompt for your agent: