Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use for queue and scheduled not supported #3

Open
JorritSalverda opened this issue Aug 31, 2023 · 0 comments
Open

Use for queue and scheduled not supported #3

JorritSalverda opened this issue Aug 31, 2023 · 0 comments

Comments

@JorritSalverda
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant