Skip to content

Commit f4631c4

Browse files
authored
fix(compute): preserve waitUntil rejection semantics (#83)
1 parent eb328b4 commit f4631c4

2 files changed

Lines changed: 8 additions & 15 deletions

File tree

packages/compute/src/scale-to-zero.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,13 @@ export function waitUntil(
139139
): void {
140140
const guard = new ScaleToZeroGuard(options);
141141

142-
void Promise.resolve(promise)
143-
.finally(() => {
142+
// Do not attach a catch here; callers rely on the underlying promise keeping
143+
// its normal unhandled-rejection behavior.
144+
void Promise.resolve(promise).finally(() => {
145+
try {
144146
guard.release();
145-
})
146-
.catch(() => {});
147+
} catch {
148+
// Guard cleanup must not replace the application promise's result.
149+
}
150+
});
147151
}

packages/compute/tests/scale-to-zero.test.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,6 @@ describe("scale-to-zero guard", () => {
8383
expect(await readSignals(file)).toBe("+-");
8484
});
8585

86-
it("waitUntil releases after the promise rejects", async () => {
87-
const { file } = await createControlFile();
88-
const promise = Promise.reject(new Error("background failed"));
89-
90-
expect(waitUntil(promise)).toBeUndefined();
91-
await expect(promise).rejects.toThrow("background failed");
92-
await Promise.resolve();
93-
94-
expect(await readSignals(file)).toBe("+-");
95-
});
96-
9786
it("waitUntil signal abort releases before a still-pending promise settles", async () => {
9887
const { file } = await createControlFile();
9988
const controller = new AbortController();

0 commit comments

Comments
 (0)