Open
Description
Working on trying to identify what causes a memory access out of bounds CompileError
in some queue handlers - see cloudflare/workers-rs#374 - I stumbled upon the fact that I can't use recordCoredump
for workers that handle queue events or cron triggers, since they lack a request
object.
My entry.mjs
file looks as follows:
import shim, { getMemory, wasmModule } from "../build/worker/shim.mjs"
import { recordCoredump } from "@cloudflare/wasm-coredump"
const timeoutSecs = 60;
async function fetch(request, env, ctx) {
try {
// see https://github.com/rustwasm/wasm-bindgen/issues/2724.
return await Promise.race([
shim.fetch(request, env, ctx),
new Promise((r, e) => setTimeout(() => e("timeout"), timeoutSecs * 1000))
]);
} catch (err) {
console.error(err);
const memory = getMemory();
const coredumpService = env.COREDUMP_SERVICE;
await recordCoredump({ memory, wasmModule, request, coredumpService });
throw err;
}
}
async function queue(batch, env, ctx) {
try {
// see https://github.com/rustwasm/wasm-bindgen/issues/2724.
return await Promise.race([
shim.queue(batch, env, ctx),
new Promise((r, e) => setTimeout(() => e("timeout"), timeoutSecs * 1000))
]);
} catch (err) {
console.error(err);
const memory = getMemory();
const coredumpService = env.COREDUMP_SERVICE;
await recordCoredump({ memory, wasmModule, request, coredumpService });
throw err;
}
}
async function scheduled(event, env, ctx) {
try {
// see https://github.com/rustwasm/wasm-bindgen/issues/2724.
return await Promise.race([
shim.scheduled(event, env, ctx),
new Promise((r, e) => setTimeout(() => e("timeout"), timeoutSecs * 1000))
]);
} catch (err) {
console.error(err);
const memory = getMemory();
const coredumpService = env.COREDUMP_SERVICE;
await recordCoredump({ memory, wasmModule, request, coredumpService });
throw err;
}
}
export default { fetch, queue, scheduled };
However the calls to recordCoredump
from queue
and scheduled
fail with exception:
"exceptions": [
{
"name": "ReferenceError",
"message": "request is not defined",
"timestamp": 1693489675116
}
],
It would be nice if the request
parameter was made optional and handled without error if it's not passed, so that I can perform core dumps for cron triggers and queue consumers.
Metadata
Metadata
Assignees
Labels
No labels