-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(rendering): allow framework renders to be cancelled #10448
Changes from all commits
5fc04b9
b5c2c13
97cc5b0
68afd5e
74e48f3
637c0ef
cba64a1
dd66cdf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"astro": patch | ||
--- | ||
|
||
Fixes an issue where multiple rendering errors resulted in a crash of the SSR app server. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import react from "@astrojs/react" | ||
|
||
export default { | ||
integrations: [ react() ] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default function ReactComp({ foo }: { foo: { bar: { baz: string[] } } }) { | ||
return ( | ||
<div> | ||
React Comp | ||
{foo.bar.baz.length} | ||
</div> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
import ReactComp from '../components/react.tsx'; | ||
|
||
const foo = { bar: null } as any; | ||
--- | ||
<ReactComp foo={foo} /> | ||
{foo.bar.baz.length > 0 && <div/>} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,9 @@ import assert from 'node:assert/strict'; | |
import { after, before, describe, it } from 'node:test'; | ||
import * as cheerio from 'cheerio'; | ||
import testAdapter from './test-adapter.js'; | ||
import { isWindows, loadFixture, streamAsyncIterator } from './test-utils.js'; | ||
import { loadFixture, streamAsyncIterator } from './test-utils.js'; | ||
|
||
describe('Streaming', () => { | ||
if (isWindows) return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test suite passes on windows. Was there another reason these were skipped? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No idea, to be honest. But if it passes, happy days! |
||
|
||
/** @type {import('./test-utils').Fixture} */ | ||
let fixture; | ||
|
||
|
@@ -79,12 +77,20 @@ describe('Streaming', () => { | |
} | ||
assert.equal(chunks.length > 1, true); | ||
}); | ||
|
||
// if the offshoot promise goes unhandled, this test will pass immediately but fail the test suite | ||
it('Stays alive on failed component renders initiated by failed render templates', async () => { | ||
const app = await fixture.loadTestAdapterApp(); | ||
const request = new Request('http://example.com/multiple-errors'); | ||
const response = await app.render(request); | ||
assert.equal(response.status, 500); | ||
const text = await response.text(); | ||
assert.equal(text, ''); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Streaming disabled', () => { | ||
if (isWindows) return; | ||
|
||
/** @type {import('./test-utils').Fixture} */ | ||
let fixture; | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking we can wrap this entire function body with a
try..catch
, but this also works for me.