-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Catch errors that occur within the stream in the Node adapter (#6935)
* Catch errors that occur within the stream in the Node adapter * Adding a changeset * Better error message on completely uncaught errors within the stream * Update test
- Loading branch information
Showing
6 changed files
with
76 additions
and
2 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 @@ | ||
--- | ||
'@astrojs/node': patch | ||
--- | ||
|
||
Catch errors that occur within the stream in the Node adapter |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import nodejs from '../dist/index.js'; | ||
import { loadFixture } from './test-utils.js'; | ||
import { expect } from 'chai'; | ||
import * as cheerio from 'cheerio'; | ||
|
||
describe('Errors', () => { | ||
let fixture; | ||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/errors/', | ||
output: 'server', | ||
adapter: nodejs({ mode: 'standalone' }), | ||
}); | ||
await fixture.build(); | ||
}); | ||
describe('Within the stream', async () => { | ||
let devPreview; | ||
|
||
before(async () => { | ||
devPreview = await fixture.preview(); | ||
}); | ||
after(async () => { | ||
await devPreview.stop(); | ||
}); | ||
it('when mode is standalone', async () => { | ||
const res = await fixture.fetch('/in-stream'); | ||
const html = await res.text(); | ||
const $ = cheerio.load(html); | ||
|
||
expect($('p').text().trim()).to.equal('Internal server error'); | ||
}); | ||
}); | ||
}); |
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 @@ | ||
{ | ||
"name": "@test/nodejs-errors", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*", | ||
"@astrojs/node": "workspace:*" | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/integrations/node/test/fixtures/errors/src/pages/in-stream.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,13 @@ | ||
--- | ||
--- | ||
<html> | ||
<head> | ||
<title>One</title> | ||
</head> | ||
<body> | ||
<h1>One</h1> | ||
<p> | ||
{Promise.reject('Error in the stream')} | ||
</p> | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.