-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
fix: bubble up errors in rewrites (#11136)
* fix: bubble up errors in rewrites * docs * remove commented code * changesets * fix string interpolation
- create-astro@4.11.0
- create-astro@4.11.0-beta.1
- create-astro@4.11.0-beta.0
- create-astro@4.10.0
- create-astro@4.9.2
- create-astro@4.9.1
- create-astro@4.9.0
- create-astro@4.8.4
- create-astro@4.8.4-alpha.0
- create-astro@4.8.3
- create-astro@4.8.2
- create-astro@4.8.1
- @astrojs/web-vitals@3.0.1
- @astrojs/web-vitals@3.0.0
- @astrojs/web-vitals@3.0.0-beta.1
- @astrojs/web-vitals@2.0.1-alpha.0
- @astrojs/web-vitals@2.0.0
- @astrojs/web-vitals@1.0.0
- @astrojs/vue@5.0.4
- @astrojs/vue@5.0.3
- @astrojs/vue@5.0.2
- @astrojs/vue@5.0.1
- @astrojs/vue@5.0.0
- @astrojs/vue@5.0.0-beta.3
- @astrojs/vue@5.0.0-beta.2
- @astrojs/vue@5.0.0-beta.1
- @astrojs/vue@5.0.0-beta.0
- @astrojs/vue@5.0.0-alpha.0
- @astrojs/vue@4.5.3
- @astrojs/vue@4.5.2
- @astrojs/vue@4.5.1
- @astrojs/vue@4.5.0
- @astrojs/vue@4.4.0
- @astrojs/vercel@8.0.0-alpha.1
- @astrojs/vercel@8.0.0-alpha.0
- @astrojs/vercel@7.8.0
- @astrojs/vercel@7.7.2
- @astrojs/vercel@7.7.1
- @astrojs/vercel@7.7.0
- @astrojs/upgrade@0.4.2
- @astrojs/upgrade@0.4.1
- @astrojs/upgrade@0.4.0
- @astrojs/upgrade@0.4.0-beta.0
- @astrojs/upgrade@0.3.4
- @astrojs/upgrade@0.3.3
- @astrojs/upgrade@0.3.2
- @astrojs/underscore-redirects@0.6.0
- @astrojs/underscore-redirects@0.5.1
- @astrojs/underscore-redirects@0.5.0
- @astrojs/underscore-redirects@0.4.0
- @astrojs/underscore-redirects@0.4.0-beta.1
- @astrojs/underscore-redirects@0.4.0-alpha.0
- @astrojs/underscore-redirects@0.3.4
- @astrojs/telemetry@3.2.0
- @astrojs/telemetry@3.2.0-beta.0
- @astrojs/tailwind@6.0.0-alpha.0
- @astrojs/tailwind@5.1.4
- @astrojs/tailwind@5.1.3
- @astrojs/tailwind@5.1.2
- @astrojs/tailwind@5.1.1
- @astrojs/svelte@7.0.3
- @astrojs/svelte@7.0.2
- @astrojs/svelte@7.0.1
- @astrojs/svelte@7.0.0
- @astrojs/svelte@7.0.0-beta.1
- @astrojs/svelte@6.0.2
- @astrojs/svelte@6.0.2-beta.0
- @astrojs/svelte@6.0.1
- @astrojs/svelte@6.0.0
- @astrojs/svelte@6.0.0-beta.2
- @astrojs/svelte@6.0.0-beta.1
- @astrojs/svelte@6.0.0-beta.0
- @astrojs/svelte@6.0.0-alpha.0
- @astrojs/svelte@5.7.3
- @astrojs/svelte@5.7.2
- @astrojs/svelte@5.7.1
- @astrojs/svelte@5.7.0
- @astrojs/svelte@5.6.0
- @astrojs/svelte@5.5.0
- @astrojs/studio@0.1.3
- @astrojs/studio@0.1.2
- @astrojs/studio@0.1.2-beta.0
- @astrojs/studio@0.1.1
- @astrojs/solid-js@5.0.1
- @astrojs/solid-js@5.0.0
- @astrojs/solid-js@5.0.0-beta.1
- @astrojs/solid-js@4.4.4
- @astrojs/solid-js@4.4.4-beta.0
- @astrojs/solid-js@4.4.3
- @astrojs/solid-js@4.4.2
- @astrojs/solid-js@4.4.1
- @astrojs/solid-js@4.4.0
- @astrojs/solid-js@4.3.0
- @astrojs/sitemap@3.2.1
- @astrojs/sitemap@3.2.0
- @astrojs/sitemap@3.1.6
- @astrojs/rss@4.0.11
- @astrojs/rss@4.0.10
- @astrojs/rss@4.0.9
- @astrojs/rss@4.0.8
- @astrojs/rss@4.0.7
- @astrojs/react@4.1.3
- @astrojs/react@4.1.2
- @astrojs/react@4.1.1
- @astrojs/react@4.1.0
- @astrojs/react@4.0.0
- @astrojs/react@4.0.0-beta.2
- @astrojs/react@3.7.0-beta.1
- @astrojs/react@3.6.3
- @astrojs/react@3.6.3-beta.0
- @astrojs/react@3.6.2
- @astrojs/react@3.6.1
- @astrojs/react@3.6.0
- @astrojs/react@3.5.0
- @astrojs/prism@3.2.0
- @astrojs/prism@3.2.0-beta.0
- @astrojs/preact@4.0.1
- @astrojs/preact@4.0.0
- @astrojs/preact@4.0.0-beta.1
- @astrojs/preact@3.5.4
- @astrojs/preact@3.5.4-beta.0
- @astrojs/preact@3.5.3
- @astrojs/preact@3.5.2
- @astrojs/preact@3.5.1
- @astrojs/preact@3.5.0
- @astrojs/preact@3.4.0
- @astrojs/partytown@2.1.3
- @astrojs/partytown@2.1.2
- @astrojs/partytown@2.1.1
- @astrojs/node@9.0.0-alpha.1
- @astrojs/node@9.0.0-alpha.0
- @astrojs/node@8.3.3
- @astrojs/node@8.3.2
- @astrojs/node@8.3.1
- @astrojs/node@8.3.0
- @astrojs/node@8.2.6
- @astrojs/mdx@4.0.5
- @astrojs/mdx@4.0.4
- @astrojs/mdx@4.0.3
- @astrojs/mdx@4.0.2
- @astrojs/mdx@4.0.1
- @astrojs/mdx@4.0.0
- @astrojs/mdx@4.0.0-beta.5
- @astrojs/mdx@4.0.0-beta.4
- @astrojs/mdx@4.0.0-beta.3
- @astrojs/mdx@4.0.0-beta.2
- @astrojs/mdx@4.0.0-beta.1
- @astrojs/mdx@4.0.0-alpha.2
- @astrojs/mdx@4.0.0-alpha.1
- @astrojs/mdx@4.0.0-alpha.0
- @astrojs/mdx@3.1.9
- @astrojs/mdx@3.1.8
- @astrojs/mdx@3.1.7
- @astrojs/mdx@3.1.6
- @astrojs/mdx@3.1.5
- @astrojs/mdx@3.1.4
- @astrojs/mdx@3.1.3
- @astrojs/mdx@3.1.2
- @astrojs/mdx@3.1.1
- @astrojs/mdx@3.1.0
- @astrojs/markdown-remark@6.0.1
- @astrojs/markdown-remark@6.0.0
- @astrojs/markdown-remark@6.0.0-beta.3
- @astrojs/markdown-remark@6.0.0-beta.2
- @astrojs/markdown-remark@6.0.0-beta.1
- @astrojs/markdown-remark@6.0.0-alpha.1
- @astrojs/markdown-remark@6.0.0-alpha.0
- @astrojs/markdown-remark@5.3.0
- @astrojs/markdown-remark@5.2.0
- @astrojs/markdown-remark@5.1.1
- @astrojs/markdoc@1.0.0-alpha.1
- @astrojs/markdoc@1.0.0-alpha.0
- @astrojs/markdoc@0.12.5
- @astrojs/markdoc@0.12.4
- @astrojs/markdoc@0.12.3
- @astrojs/markdoc@0.12.2
- @astrojs/markdoc@0.12.1
- @astrojs/markdoc@0.12.0
- @astrojs/markdoc@0.12.0-beta.1
- @astrojs/markdoc@0.12.0-beta.0
- @astrojs/markdoc@0.11.5
- @astrojs/markdoc@0.11.5-beta.1
- @astrojs/markdoc@0.11.5-beta.0
- @astrojs/markdoc@0.11.4
- @astrojs/markdoc@0.11.3
- @astrojs/markdoc@0.11.2
- @astrojs/markdoc@0.11.1
- @astrojs/lit@4.3.0
- @astrojs/lit@4.2.0
- @astrojs/internal-helpers@0.4.2
- @astrojs/internal-helpers@0.4.1
- @astrojs/db@0.14.5
- @astrojs/db@0.14.4
- @astrojs/db@0.14.3
- @astrojs/db@0.14.2
- @astrojs/db@0.14.1
- @astrojs/db@0.14.0
- @astrojs/db@0.14.0-beta.2
- @astrojs/db@0.14.0-beta.1
- @astrojs/db@0.13.2
- @astrojs/db@0.13.2-alpha.1
- @astrojs/db@0.13.2-alpha.0
- @astrojs/db@0.13.1
- @astrojs/db@0.13.0
- @astrojs/db@0.12.0
- @astrojs/db@0.11.7
- @astrojs/db@0.11.6
- @astrojs/db@0.11.5
- @astrojs/alpinejs@0.4.1
- astro@5.1.5
- astro@5.1.4
- astro@5.1.3
- astro@5.1.2
- astro@5.1.1
- astro@5.1.0
- astro@5.0.9
- astro@5.0.8
- astro@5.0.7
- astro@5.0.6
- astro@5.0.5
- astro@5.0.4
- astro@5.0.3
- astro@5.0.2
- astro@5.0.1
- astro@5.0.0
- astro@5.0.0-beta.12
- astro@5.0.0-beta.11
- astro@5.0.0-beta.10
- astro@5.0.0-beta.9
- astro@5.0.0-beta.8
- astro@5.0.0-beta.7
- astro@5.0.0-beta.6
- astro@5.0.0-beta.5
- astro@5.0.0-beta.4
- astro@5.0.0-beta.3
- astro@5.0.0-beta.2
- astro@5.0.0-beta.1
- astro@5.0.0-alpha.8
- astro@5.0.0-alpha.7
- astro@5.0.0-alpha.6
- astro@5.0.0-alpha.5
- astro@5.0.0-alpha.4
- astro@5.0.0-alpha.3
- astro@5.0.0-alpha.2
- astro@5.0.0-alpha.1
- astro@5.0.0-alpha.0
- astro@4.16.18
- astro@4.16.17
- astro@4.16.16
- astro@4.16.15
- astro@4.16.14
- astro@4.16.13
- astro@4.16.12
- astro@4.16.11
- astro@4.16.10
- astro@4.16.9
- astro@4.16.8
- astro@4.16.7
- astro@4.16.6
- astro@4.16.5
- astro@4.16.4
- astro@4.16.3
- astro@4.16.2
- astro@4.16.1
- astro@4.16.0
- astro@4.15.12
- astro@4.15.11
- astro@4.15.10
- astro@4.15.9
- astro@4.15.8
- astro@4.15.7
- astro@4.15.6
- astro@4.15.5
- astro@4.15.4
- astro@4.15.3
- astro@4.15.2
- astro@4.15.1
- astro@4.15.0
- astro@4.14.6
- astro@4.14.5
- astro@4.14.4
- astro@4.14.3
- astro@4.14.2
- astro@4.14.1
- astro@4.14.0
- astro@4.13.4
- astro@4.13.3
- astro@4.13.2
- astro@4.13.1
- astro@4.13.0
- astro@4.12.3
- astro@4.12.2
- astro@4.12.1
- astro@4.12.0
- astro@4.11.6
- astro@4.11.5
- astro@4.11.4
- astro@4.11.3
- astro@4.11.2
- astro@4.11.1
- astro@4.11.0
- astro@4.10.3
- astro@4.10.2
- astro@4.10.1
- astro@4.10.0
Showing
24 changed files
with
360 additions
and
167 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"astro": patch | ||
--- | ||
|
||
Errors that are emitted during a rewrite are now bubbled up and shown to the user. A 404 response is not returned anymore. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"astro": patch | ||
--- | ||
|
||
It's not possible anymore to use `Astro.rewrite("/404")` inside static pages. This isn't counterproductive because Astro will end-up emitting a page that contains the HTML of 404 error page. | ||
|
||
It's still possible to use `Astro.rewrite("/404")` inside on-demand pages, or pages that opt-out from prerendering. |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
44 changes: 31 additions & 13 deletions
44
packages/astro/src/core/routing/astro-designed-error-pages.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,38 @@ | ||
import type { ManifestData } from '../../@types/astro.js'; | ||
import type { ManifestData, RouteData } from '../../@types/astro.js'; | ||
import notFoundTemplate from '../../template/4xx.js'; | ||
import { DEFAULT_404_COMPONENT } from '../constants.js'; | ||
|
||
export const DEFAULT_404_ROUTE: RouteData = { | ||
component: DEFAULT_404_COMPONENT, | ||
generate: () => '', | ||
params: [], | ||
pattern: /\/404/, | ||
prerender: false, | ||
pathname: '/404', | ||
segments: [[{ content: '404', dynamic: false, spread: false }]], | ||
type: 'page', | ||
route: '/404', | ||
fallbackRoutes: [], | ||
isIndex: false, | ||
}; | ||
|
||
export function ensure404Route(manifest: ManifestData) { | ||
if (!manifest.routes.some((route) => route.route === '/404')) { | ||
manifest.routes.push({ | ||
component: DEFAULT_404_COMPONENT, | ||
generate: () => '', | ||
params: [], | ||
pattern: /\/404/, | ||
prerender: false, | ||
segments: [[{ content: '404', dynamic: false, spread: false }]], | ||
type: 'page', | ||
route: '/404', | ||
fallbackRoutes: [], | ||
isIndex: false, | ||
}); | ||
manifest.routes.push(DEFAULT_404_ROUTE); | ||
} | ||
return manifest; | ||
} | ||
|
||
export async function default404Page({ pathname }: { pathname: string }) { | ||
return new Response( | ||
notFoundTemplate({ | ||
statusCode: 404, | ||
title: 'Not found', | ||
tabTitle: '404: Not Found', | ||
pathname, | ||
}), | ||
{ status: 404, headers: { 'Content-Type': 'text/html; charset=utf-8' } } | ||
); | ||
} | ||
// mark the function as an AstroComponentFactory for the rendering internals | ||
default404Page.isAstroComponentFactory = true; |
This file contains 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
This file contains 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
This file contains 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
11 changes: 0 additions & 11 deletions
11
packages/astro/test/fixtures/reroute/src/pages/blog/oops.astro
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
packages/astro/test/fixtures/rewrite-404-invalid/astro.config.mjs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig } from 'astro/config'; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
experimental: { | ||
rewriting: true | ||
}, | ||
site: "https://example.com" | ||
}); |
8 changes: 8 additions & 0 deletions
8
packages/astro/test/fixtures/rewrite-404-invalid/package.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "@test/rewrite-404-invalid", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*" | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/astro/test/fixtures/rewrite-404-invalid/src/pages/rewrite-404.astro
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
return Astro.rewrite("/404") | ||
--- |
9 changes: 9 additions & 0 deletions
9
packages/astro/test/fixtures/rewrite-runtime-error/astro.config.mjs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig } from 'astro/config'; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
experimental: { | ||
rewriting: true | ||
}, | ||
site: "https://example.com" | ||
}); |
8 changes: 8 additions & 0 deletions
8
packages/astro/test/fixtures/rewrite-runtime-error/package.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "@test/rewrite-runtime-errror", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*" | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/astro/test/fixtures/rewrite-runtime-error/src/pages/errors/from.astro
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
return Astro.rewrite('/errors/to'); | ||
--- | ||
<div></div> |
4 changes: 4 additions & 0 deletions
4
packages/astro/test/fixtures/rewrite-runtime-error/src/pages/errors/to.astro
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
throw new Error('Custom error') | ||
--- | ||
<div></div> |
This file contains 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
Oops, something went wrong.