Skip to content

Commit db9bb2e

Browse files
morinokamiclaude
andcommitted
fix(void): log unmatched queues on every delivery path
When no handler matched a queue, only the native queue() logged the reason. The HTTP route returned it as `error`, which the Void Cloud relay ignores, so a batch for an unknown queue was retried with nothing logged. Log the reason in __processQueue, where handler errors are logged, and drop the native queue()'s own log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8F8mZUqZxveCneED8EgLC
1 parent b42d421 commit db9bb2e

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

‎packages/void/src/router/compile.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -559,15 +559,17 @@ export function compileRouteTable(
559559
lines.push(`const __queueLabels = ${JSON.stringify(queueLabels)};`);
560560
// Queue dispatch as a standalone function — called directly by native queue handler
561561
// and via the authenticated HTTP route. No global mutable state needed.
562-
// It logs a handler's error. Otherwise Cloudflare would record only the native
563-
// handler's "queue: Handler failed.", and the dev server and Void Cloud nothing.
562+
// It logs why a batch failed: the native handler throws only "queue: Handler failed.",
563+
// the HTTP route returns no handler error, and the Void Cloud relay ignores `error`.
564564
lines.push('export async function __processQueue(payload, env) {');
565565
lines.push(' const queueSuffix = payload.queue;');
566566
lines.push(' const __queueIndex = __resolveQueueIndex(queueSuffix);');
567567
lines.push(' if (__queueIndex === -1) {');
568568
lines.push(
569-
' return { ok: false, error: `No unambiguous queue handler matches "${String(queueSuffix)}"` };',
569+
' const __error = `No unambiguous queue handler matches "${String(queueSuffix)}"`;',
570570
);
571+
lines.push(' console.error(`[void] ${__error}`);');
572+
lines.push(' return { ok: false, error: __error };');
571573
lines.push(' }');
572574
lines.push(' const __decisions = new Map();');
573575
lines.push(' function __wrapMsg(m) {');
@@ -1356,7 +1358,6 @@ ${envValidateCall}${remoteEnvSwap}${isrDeploymentStamp} const userEnv = __filte
13561358
else if (d.action === "retry") m.retry(d.delaySeconds != null ? { delaySeconds: d.delaySeconds } : undefined);
13571359
}
13581360
}
1359-
if (__qr.error) console.error(\`[void] \${__qr.error}\`);
13601361
if (!__qr.ok) throw new Error("queue: Handler failed.");
13611362
}
13621363

‎packages/void/test/integration/queue-dispatch.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ export { __processQueue } from "virtual:void-routes";\n`,
183183
expect(env.calls).toEqual([{ handler: expectedHandler, queue, attempts: [2, 3], dates: true }]);
184184
});
185185

186-
it('returns failure without dispatching an unknown logical or physical queue', async () => {
186+
it('logs and returns failure without dispatching an unknown logical or physical queue', async () => {
187+
const errorLog = vi.spyOn(console, 'error').mockImplementation(() => {});
187188
for (const queue of ['unknown', 'project-unknown']) {
188189
const env = { calls: [] as Array<Record<string, unknown>> };
189190
const result = await generated.__processQueue(payload(queue), env);
@@ -194,6 +195,10 @@ export { __processQueue } from "virtual:void-routes";\n`,
194195
});
195196
expect(env.calls).toEqual([]);
196197
}
198+
expect(errorLog.mock.calls).toEqual([
199+
['[void] No unambiguous queue handler matches "unknown"'],
200+
['[void] No unambiguous queue handler matches "project-unknown"'],
201+
]);
197202
});
198203

199204
it('logs a failed handler with its file and queue and returns failure', async () => {

0 commit comments

Comments
 (0)