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 CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Unreleased

- `@openstatus/health`: Probes no longer start work if an async `skip`
returns `false` after the timeout. The completed timeout report stays unchanged.

## 0.1.2

- Every hosting package (`fly`, `koyeb`, `railway`, `vercel`, `cloudflare`)
Expand Down
21 changes: 21 additions & 0 deletions packages/health/src/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,27 @@ test("runProbes() times out a hanging skip()", async () => {
assert.equal(report.checks[0].status, "timeout");
});

test("runProbes() does not start work when skip() resolves false after timeout", async () => {
const skip = Promise.withResolvers<boolean>();
let ran = false;
const report = await runProbes([{
name: "a",
timeoutMs: 10,
skip: () => skip.promise,
run: () => {
ran = true;
},
}]);
assert.equal(report.checks[0].status, "timeout");
const completed = structuredClone(report);

skip.resolve(false);
await delay(0);

assert.equal(ran, false);
assert.deepEqual(report, completed);
});

test("runProbes() passes name, critical and timeoutMs to run()", async () => {
let seen: { name: string; critical: boolean; timeoutMs: number } | undefined;
await runProbes([{
Expand Down
1 change: 1 addition & 0 deletions packages/health/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ async function runProbe(

const work = Promise.resolve().then(async () => {
if (await probe.skip?.()) return "skipped";
controller.signal.throwIfAborted();
await probe.run(controller.signal, ctx);
return "ok";
});
Expand Down
Loading