@@ -374,6 +374,7 @@ describe("Component", () => {
|
||||
React.use(pending)
|
||||
return <div>committed</div>
|
||||
}).pipe(
|
||||
Component.withOptions({ scopeCommitTimeout: "10 millis" }),
|
||||
Component.withContext(runtime.context)
|
||||
)
|
||||
|
||||
@@ -414,7 +415,10 @@ describe("Component", () => {
|
||||
|
||||
return <div>committed</div>
|
||||
}).pipe(
|
||||
Component.withOptions({ finalizerExecutionDebounce: "10 millis" }),
|
||||
Component.withOptions({
|
||||
finalizerExecutionDebounce: "10 millis",
|
||||
scopeCommitTimeout: "10 millis",
|
||||
}),
|
||||
Component.withContext(runtime.context),
|
||||
)
|
||||
|
||||
@@ -437,6 +441,42 @@ describe("Component", () => {
|
||||
await runtime.runtime.dispose()
|
||||
})
|
||||
|
||||
it("does not expire a scope while a descendant is suspended past the finalizer debounce", async () => {
|
||||
const runtime = ReactRuntime.make(Layer.empty)
|
||||
let resolve!: () => void
|
||||
const pending = new Promise<void>(complete => {
|
||||
resolve = complete
|
||||
})
|
||||
|
||||
const Suspended = () => {
|
||||
React.use(pending)
|
||||
return <div>committed</div>
|
||||
}
|
||||
|
||||
let view!: ReturnType<typeof render>
|
||||
await act(async () => {
|
||||
view = render(
|
||||
<ReactRuntime.Provider runtime={runtime} fallback={<div>fallback</div>}>
|
||||
<Suspended />
|
||||
</ReactRuntime.Provider>
|
||||
)
|
||||
})
|
||||
|
||||
try {
|
||||
await screen.findByText("fallback")
|
||||
await new Promise(resolve => setTimeout(resolve, 150))
|
||||
await act(async () => {
|
||||
resolve()
|
||||
await pending
|
||||
})
|
||||
await screen.findByText("committed")
|
||||
}
|
||||
finally {
|
||||
view.unmount()
|
||||
await runtime.runtime.dispose()
|
||||
}
|
||||
})
|
||||
|
||||
it("clears ScopeRegistry after a suspended render retries, commits, and unmounts", async () => {
|
||||
const lifecycle = vi.fn<(message: string) => void>()
|
||||
const runtime = ReactRuntime.make(Layer.empty)
|
||||
@@ -455,6 +495,7 @@ describe("Component", () => {
|
||||
}), [])
|
||||
return <div>committed</div>
|
||||
}).pipe(
|
||||
Component.withOptions({ scopeCommitTimeout: "10 millis" }),
|
||||
Component.withContext(runtime.context)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user