fix: add handleInvalidUrl prerender option for non-HTTP URL schemes#16088
Merged
Rich-Harris merged 2 commits intoJun 22, 2026
Merged
Conversation
Fixes sveltejs#15935 URLs with non-standard schemes (e.g. AT Protocol `at://did:plc:...` used for Bluesky identity verification via `<link rel="me">`) throw `TypeError: Invalid URL` inside the prerender crawler, crashing the build with an unhelpful stack trace and no way to suppress the failure. The crawler now catches URL parse errors and collects the raw href values in an `invalid` array returned alongside `ids` and `hrefs`. The prerender runner routes each one through a new `handleInvalidUrl` handler (default `'fail'`) that follows the same `'fail' | 'warn' | 'ignore' | function` pattern as `handleHttpError` and friends, including a helpful error message pointing to the config option.
🦋 Changeset detectedLatest commit: b1a0367 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
teemingc
reviewed
Jun 22, 2026
Co-authored-by: Tee Ming <chewteeming01@gmail.com>
elliott-with-the-longest-name-on-github
approved these changes
Jun 22, 2026
Member
|
thank you! |
Merged
Rich-Harris
pushed a commit
that referenced
this pull request
Jun 22, 2026
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @sveltejs/kit@2.67.0 ### Minor Changes - feat: add `prerender.handleInvalidUrl` option for invalid URLs discovered while crawling ([#16088](#16088)) ### Patch Changes - fix: support `exactOptionalPropertyTypes` for optional form schema fields ([#15866](#15866)) - fix: avoid unnecessarily overriding a user's Vite 8 `codeSplitting` setting ([#16118](#16118)) ## @sveltejs/adapter-node@5.5.6 ### Patch Changes - fix: avoid circular dependency between server initialisation and hook retrieval that causes the app to crash on start ([#16115](#16115)) - fix: correctly resolve root directory on the server ([#16114](#16114)) - fix: ensure `ENV_PREFIX` is defined ([#16106](#16106)) - Updated dependencies [[`cf15fa0`](cf15fa0), [`5c76121`](5c76121), [`2992e17`](2992e17)]: - @sveltejs/kit@2.67.0 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
closes #15935
When SvelteKit's prerender crawler encounters a URL scheme it cannot parse — like an AT Protocol URL (
at://did:plc:...) — callingnew URL(href, base)throws an unhandledTypeErrorand crashes the build. Since the AT Protocol identifier syntax embeds colons inside the host segment, WHATWG URL parsing interprets the part after the first colon as an invalid port number.This adds a
handleInvalidUrloption toconfig.prerender, following the samenormalise_error_handlerpattern already used byhandleHttpError,handleMissingId, andhandleUnseenRoutes. The default behavior throws with a message pointing users to the docs. Setting it to'warn'or'ignore'lets a build continue, and a custom function receives{ href, referrer, message }.The crawl function now collects URLs that throw into an
invalid[]array instead of crashing immediately, andprerender.jsiterates that array to invoke the configured handler for each one.Thanks to @Rich-Harris for proposing this exact design in #15935.