Skip to content

Commit 61e6308

Browse files
committed
fix(observability): retain queue failure source locations
1 parent 6224135 commit 61e6308

5 files changed

Lines changed: 94 additions & 12 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ checkpoint, and status-only commits are intentionally omitted.
7272

7373
### Fixed
7474

75+
- Retain numeric queue failure source locations inside the Durable Object before remote transport discards the original stack, without logging private error text.
7576
- Bound shared repair GitHub CLI calls with native process deadlines and honor per-call timeout settings. Thanks @SebTardif.
7677
- Bound standalone webhook GitHub requests to 15 seconds, including response bodies, so stalled calls return a retryable response. Thanks @SebTardif.
7778
- Completed obsolete exact-review publications when apply verifies a strictly newer durable review for the same revision, preserving retry behavior for unproven results. Thanks @vincentkoc. (#1249)

‎dashboard/exact-review-queue.ts‎

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,22 @@ function exactReviewPublicBayRepositories(env): Set<string> {
731731
return new Set(repositories);
732732
}
733733

734+
function rethrowQueueFailure(error: unknown, phase: "initialize" | "fetch"): never {
735+
const stack = objectValue(error).stack;
736+
// Remote error text may contain private data; retain only deployed source coordinates.
737+
const frame =
738+
typeof stack === "string"
739+
? /^[ \t]+at (?:[^\r\n]*[/ (])?worker\.js:([1-9]\d{0,5}):([1-9]\d{0,5})\)?[ \t]*\r?$/m.exec(
740+
stack,
741+
)
742+
: null;
743+
console.error("exact_review_queue_handler_failed", {
744+
phase,
745+
location: frame ? [Number(frame[1]), Number(frame[2])] : null,
746+
});
747+
throw error;
748+
}
749+
734750
export class ExactReviewQueue {
735751
private state;
736752
private storage;
@@ -789,20 +805,34 @@ export class ExactReviewQueue {
789805
if (typeof state.blockConcurrencyWhile === "function") {
790806
this.lifecycleProjectionReady = Promise.resolve(
791807
state.blockConcurrencyWhile(async () => {
792-
this.lifecycleProjectionStore.ensureSchemaSync();
793-
this.lifecycleTelemetryStore.ensureSchemaSync();
794-
this.lifecycleTelemetryStore.syncBayRepositoryScope(
795-
exactReviewPublicBayRepositories(this.env),
796-
);
808+
try {
809+
this.lifecycleProjectionStore.ensureSchemaSync();
810+
this.lifecycleTelemetryStore.ensureSchemaSync();
811+
this.lifecycleTelemetryStore.syncBayRepositoryScope(
812+
exactReviewPublicBayRepositories(this.env),
813+
);
814+
} catch (error) {
815+
rethrowQueueFailure(error, "initialize");
816+
}
797817
}),
798818
);
799819
} else {
800-
this.ready = this.initializeStorage();
820+
this.ready = this.initializeStorage().catch((error) =>
821+
rethrowQueueFailure(error, "initialize"),
822+
);
801823
this.lifecycleProjectionReady = this.ready;
802824
}
803825
}
804826

805827
async fetch(request: Request) {
828+
try {
829+
return await this.handleFetch(request);
830+
} catch (error) {
831+
rethrowQueueFailure(error, "fetch");
832+
}
833+
}
834+
835+
private async handleFetch(request: Request) {
806836
const url = new URL(request.url);
807837
// This is deliberately the only route that may observe lifecycle rows
808838
// before full queue initialization. Its constructor-managed schema barrier
@@ -4679,7 +4709,8 @@ export class ExactReviewQueue {
46794709

46804710
private ensureReady() {
46814711
if (this.ready) return this.ready;
4682-
const initialize = () => this.initializeStorage();
4712+
const initialize = () =>
4713+
this.initializeStorage().catch((error) => rethrowQueueFailure(error, "initialize"));
46834714
this.ready =
46844715
typeof this.state.blockConcurrencyWhile === "function"
46854716
? Promise.resolve(this.state.blockConcurrencyWhile(initialize))

‎docs/live-dashboard.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ Queue transport failures keep the fixed public `exact_review_queue_unavailable`
3434
response. Server logs for `exact_review_queue_request_failed` retain only the
3535
Cloudflare `remote`, `retryable`, and `overloaded` boolean flags; exception text,
3636
stacks, request payloads, and credentials are excluded. These flags are diagnostic
37-
signals and do not change retry or publication policy.
37+
signals and do not change retry or publication policy. Inside the Durable Object,
38+
`exact_review_queue_handler_failed` additionally records `initialize` or `fetch`
39+
and the first numeric `[line, column]` location in the deployed `worker.js` module
40+
(or `null` when unavailable). Match coordinates to that deployment’s bundle;
41+
remote transport replaces the original stack before the outer Worker sees it.
42+
These logs exclude error messages, SQL, private paths, and raw stacks.
3843

3944
## Deployment
4045

‎test/dashboard-worker-durable-object-error.test.ts‎

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,57 @@ function signedPublicationsListRequest(body: string, secret: string) {
3636
});
3737
}
3838

39-
test("exact-review Durable Object rejects storage failures directly", async () => {
39+
test("exact-review Durable Object logs only source coordinates and rethrows storage failures", async (t) => {
4040
const storage = new MemoryDurableStorage();
4141
const queue = newQueue(storage);
4242
assert.equal((await queue.fetch(publicationsListRequest(100))).status, 200);
43+
const errors: unknown[][] = [];
44+
t.mock.method(console, "error", (...values: unknown[]) => errors.push(values));
45+
for (const [stack, location] of [
46+
["Error: private marker\n at query (worker.js:91:4)", [91, 4]],
47+
[
48+
"Error: private marker\r\n at query (file:///private-path/worker.js:123:7)\r\n at caller (worker.js:234:8)",
49+
[123, 7],
50+
],
51+
["Error: private marker worker.js:91:4", null],
52+
["Error: private marker\n at query (private-worker.js:91:4)", null],
53+
["Error: private marker\n at query (worker.js:0:4)", null],
54+
["Error: private marker\n at query (worker.js:1234567:4)", null],
55+
[undefined, null],
56+
] as const) {
57+
const failure = new Error("private marker");
58+
failure.stack = stack;
59+
errors.length = 0;
60+
storage.failNextSql(/SELECT item_key, item_json/, failure);
61+
await assert.rejects(queue.fetch(publicationsListRequest(100)), (error) => error === failure);
62+
assert.deepEqual(errors, [["exact_review_queue_handler_failed", { phase: "fetch", location }]]);
63+
assert.equal((await queue.fetch(publicationsListRequest(100))).status, 200);
64+
}
65+
});
4366

44-
storage.failNextSql(/SELECT item_key, item_json/);
45-
await assert.rejects(queue.fetch(publicationsListRequest(100)), /injected SQL failure/);
46-
assert.equal((await queue.fetch(publicationsListRequest(100))).status, 200);
67+
test("exact-review schema barrier logs source coordinates before rejecting initialization", async (t) => {
68+
const storage = new MemoryDurableStorage();
69+
const failure = new Error("private schema marker");
70+
failure.stack = "Error: private schema marker\n at schema (worker.js:456:9)";
71+
storage.failNextSql(/CREATE TABLE/, failure);
72+
const errors: unknown[][] = [];
73+
t.mock.method(console, "error", (...values: unknown[]) => errors.push(values));
74+
let initialized: Promise<void> | undefined;
75+
new ExactReviewQueue(
76+
{
77+
storage,
78+
blockConcurrencyWhile: (callback: () => Promise<void>) => {
79+
initialized = callback();
80+
return initialized;
81+
},
82+
},
83+
{},
84+
);
85+
assert.ok(initialized);
86+
await assert.rejects(initialized, (error) => error === failure);
87+
assert.deepEqual(errors, [
88+
["exact_review_queue_handler_failed", { phase: "initialize", location: [456, 9] }],
89+
]);
4790
});
4891

4992
test("exact-review Worker retains only platform flags from rejected Durable Object calls", async () => {

‎test/record-export-bounds.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,9 @@ test("signed record export hides missing and invalid logical byte metadata", asy
560560
assert.equal(invalidResponse.headers.get("content-type"), "application/json; charset=utf-8");
561561
assert.deepEqual(await invalidResponse.json(), { error: "exact_review_queue_unavailable" });
562562
assert.deepEqual(errors, [
563+
["exact_review_queue_handler_failed", { phase: "fetch", location: null }],
563564
["exact_review_queue_request_failed", { remote: false, retryable: false, overloaded: false }],
565+
["exact_review_queue_handler_failed", { phase: "fetch", location: null }],
564566
["exact_review_queue_request_failed", { remote: false, retryable: false, overloaded: false }],
565567
]);
566568
} finally {

0 commit comments

Comments
 (0)