Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-vue-interrupt-tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect-app/vue": patch
---

Fix interrupt repro tests to observe expected suspense interruption rejections.
7 changes: 7 additions & 0 deletions packages/vue/test/interrupt-refetch-repro.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ const settle = (p: Promise<any> | undefined) =>
new Promise<"pending">((resolve) => setTimeout(() => resolve("pending"), 40))
])

const ignoreSuspenseInterrupt = (p: Promise<any> | undefined) => {
p?.catch(() => {})
}

const writeCommand = (repo: DataDependencies.DataDependency) => DataDependencies.write(repo).pipe(Effect.as(undefined))
const drain = (fiber: Fiber.Fiber<any, any>) =>
Effect.runPromise(Fiber.interrupt(fiber) as any).then(() => {}, () => {})
Expand All @@ -141,6 +145,7 @@ it.fails("A1 — unload during the INITIAL fetch: remount must refetch, not hang
await ticks(2)
expect(g.starts()).toBe(1)

ignoreSuspenseInterrupt(m1.getPromise())
m1.app.unmount() // page unload -> interrupt the in-flight initial fetch
await ticks(2)

Expand Down Expand Up @@ -351,6 +356,7 @@ it("M2 — one of two concurrent callers unmounts mid-fetch: the other still res
await ticks(2)
expect(g.starts()).toBe(1)

ignoreSuspenseInterrupt(a.getPromise())
a.app.unmount() // caller A loses interest -> interrupts ITS await only
await ticks(2)
g.releaseAll() // the shared fetch must survive for caller B
Expand Down Expand Up @@ -568,6 +574,7 @@ it.fails("D1 — sole listener interrupts an in-flight request; a NEW listener s
await ticks(2)
expect(g.starts()).toBe(1)

ignoreSuspenseInterrupt(l1.getPromise())
l1.app.unmount() // the only interested caller leaves -> the in-flight request should be abandoned
await ticks(2)
g.setBlocking(false)
Expand Down
Loading