Unverified Commit a6965961 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Ensure API route errors are propagated in minimal mode (#26875)

This ensures when an error occurs in an API route while using minimal mode the error is bubbled so it can be handled at the top-level 

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
parent 3b592e20
...@@ -1179,7 +1179,7 @@ export default class Server { ...@@ -1179,7 +1179,7 @@ export default class Server {
query, query,
pageModule, pageModule,
this.renderOpts.previewProps, this.renderOpts.previewProps,
false this.minimalMode
) )
return true return true
} }
......
export default async function handler(req, res) {
throw new Error('some error from /api/error')
}
...@@ -470,6 +470,15 @@ describe('Required Server Files', () => { ...@@ -470,6 +470,15 @@ describe('Required Server Files', () => {
expect(errors[0].message).toContain('gsp hit an oops') expect(errors[0].message).toContain('gsp hit an oops')
}) })
it('should bubble error correctly for API page', async () => {
errors = []
const res = await fetchViaHTTP(appPort, '/api/error')
expect(res.status).toBe(500)
expect(await res.text()).toBe('error')
expect(errors.length).toBe(1)
expect(errors[0].message).toContain('some error from /api/error')
})
it('should normalize optional values correctly for SSP page', async () => { it('should normalize optional values correctly for SSP page', async () => {
const res = await fetchViaHTTP( const res = await fetchViaHTTP(
appPort, appPort,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment