Skip to content

Fix useFetch paginated URL factory errors#75

Open
mralonsocorona wants to merge 1 commit into
raycast:mainfrom
mralonsocorona:investigate-usefetch-invalid-url
Open

Fix useFetch paginated URL factory errors#75
mralonsocorona wants to merge 1 commit into
raycast:mainfrom
mralonsocorona:investigate-usefetch-invalid-url

Conversation

@mralonsocorona

Copy link
Copy Markdown

Summary

Fixes a useFetch paginated URL factory edge case where the first page URL could be evaluated during render and throw synchronously before usePromise had a chance to expose the error through error or onError.

Problem

For static URLs, invalid URL errors happen inside the async fetch path and are handled by usePromise.

For paginated URL factories, useFetch evaluated the first page URL during render to track the first page cache key. If the URL factory threw, the error escaped before the normal async error handling path.

Changes

  • Detect paginated useFetch calls with typeof url === "function".
  • Avoid letting first page URL computation errors break render.
  • Keep paginated calls routed through the paginated fetcher even when first page URL computation fails.
  • Defer URL factory errors to the async fetch path so usePromise can expose them through its normal error handling.

Validation

  • npm run lint
  • npm run build

Fixes #64

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.

useFetch with invalid URL

1 participant