mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-12 03:05:12 +00:00
@@ -53,7 +53,12 @@ export function get_server_route_handler(routes: ServerRoute[]) {
|
||||
};
|
||||
|
||||
try {
|
||||
handle_method(req, res, handle_next);
|
||||
const result = handle_method(req, res, handle_next);
|
||||
|
||||
// catch failures in async functions
|
||||
if (Promise.resolve(result) === result) {
|
||||
result.catch(handle_next);
|
||||
}
|
||||
} catch (err) {
|
||||
handle_next(err);
|
||||
}
|
||||
|
||||
3
test/apps/errors/src/routes/async-throw.json.js
Normal file
3
test/apps/errors/src/routes/async-throw.json.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export async function get(req, res) {
|
||||
throw new Error('oops');
|
||||
}
|
||||
@@ -112,6 +112,15 @@ describe('errors', function() {
|
||||
);
|
||||
});
|
||||
|
||||
it('does not serve error page for async non-page error', async () => {
|
||||
await page.goto(`${base}/async-throw.json`);
|
||||
|
||||
assert.equal(
|
||||
await page.evaluate(() => document.body.textContent),
|
||||
'oops'
|
||||
);
|
||||
});
|
||||
|
||||
it('clears props.error on successful render', async () => {
|
||||
await page.goto(`${base}/no-error`);
|
||||
await start();
|
||||
|
||||
Reference in New Issue
Block a user