Skip to content
Myr

fix(jsx): race condition in ErrorBoundary with event loop (#3343)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fixes #3333

authored by Taku Amano · committed by GitHub · parent 040b0d4 · Browse files · 2 files+36 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+36 added−2 removed

  • tests:+28 added−0 removed
  • other:+8 added−2 removed

2 files+36 added−2 removed

modified:src/jsx/components.test.tsx+28 added
189 unmodified lines
190 suspenseCounter--191 })192 })193194 describe('async : setTimeout', async () => {195 const TimeoutSuccessComponent = async () => {196 await new Promise((resolve) => setTimeout(resolve, 10))197 return <div>OK</div>198 }199 const TimeoutErrorComponent = async () => {200 await new Promise((resolve) => setTimeout(resolve, 0))201 throw new Error('Error')202 }203204 it('fallback', async () => {205 const html = (206 <>207 <TimeoutSuccessComponent />208 <ErrorBoundary fallback={<Fallback />}>209 <TimeoutErrorComponent />210 </ErrorBoundary>211 </>212 ).toString()213214 expect((await resolveCallback(await html)).toString()).toEqual(215 '<div>OK</div><div>Out Of Service</div>'216 )217218 suspenseCounter--219 })220 })221222 describe('streaming', async () => {223 const Component = async ({ error }: { error?: boolean }) => {224 await new Promise((resolve) => setTimeout(resolve, 10))225 if (error) {
306 unmodified lines
modified:src/jsx/components.ts+8 added-2 removed