-
Notifications
You must be signed in to change notification settings - Fork 335
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
🐛 Bug Report — Runtime APIs: alarm-scheduler
fails for inscrutable reason
#1386
Comments
it is open source, it's in the capnp repo: https://github.com/capnproto/capnproto/tree/v2/c%2B%2B/src/kj |
Thanks for that—sorry! I tried looking a bit further but knowing the KJ code didn’t enlighten me much—it is hard to find where |
It's unlikely an issue in KJ. It looks like workerd is probably calling the filesystem APIs and passing a Path object that has already been freed. |
Having the same issue, really hard to debug. |
Can confirm the bug appears if |
I get this after setting the 3rd alarm regardless of how far in the future |
I’ve tried the following MWE, but I can’t reliably reproduce the bug on Wrangler export class Test implements DurableObject {
constructor(private readonly state: DurableObjectState) {}
async fetch() {
await this.state.storage.setAlarm(Date.now() - 1000);
return new Response("OK");
};
async alarm() {
console.log("Alarm execution succeeded");
}
}
const index: ExportedHandler<{ TEST: DurableObjectNamespace }> = {
fetch: async (_, { TEST }) => await TEST.get(TEST.idFromName("test")).fetch("https://do")
};
export default index; I also tried subtracting time from |
I just looked quickly at alarm-scheduler.c++ and there's currently only one place we're passing along a |
For those of you who are reliably seeing this, can I ask someone to put together a simple repro worker that always fails for you. I'm unable to reproduce the issue on main |
Okay, I have a reproduction! Use the code from above:
export class Test implements DurableObject {
constructor(private readonly state: DurableObjectState) {}
async fetch() {
await this.state.storage.setAlarm(Date.now() - 1000);
return new Response("OK");
};
async alarm() {
console.log("Alarm execution succeeded");
}
}
const index: ExportedHandler<{ TEST: DurableObjectNamespace }> = {
fetch: async (_, { TEST }) => await TEST.get(TEST.idFromName("test")).fetch("https://do")
};
export default index;
compatibility_date = "2023-11-23"
name = "debugging"
workers_dev = true
main = "./index.ts"
minify = true
[[durable_objects.bindings]]
name = "TEST"
class_name = "Test"
{
"configurations": [
{
"name": "Wrangler",
"type": "node",
"request": "attach",
"port": 9229,
"attachExistingChildren": false,
"autoAttachChildProcesses": false
}
]
} I’ve only reproduced in VS Code. The steps are:
I don’t know how many of these steps are required, but I am fairly confident this only shows up when a debugger is attached. I was able to get that repro working within 1–3 tries most of the time, occasionally it wouldn’t reproduce at all and I’d have to try step 6. I assume it doesn’t reliably reproduce because it’s memory-related? I’m not super confident about my ability to build a |
If it helps, you can use the |
Ok, think I've identified the issue and the fix (#1474) |
I've landed #1474 which should fix this issue (which is why the issue autoclosed). If you still see this issue once the workerd package is updated, let us know here and we can open this issue and keep investigating further. |
By any chance, did this change land in Workers prod around Wednesday of this week? I saw a few alarms start re-firing around (all around |
@johnspurlock James' change is a fix to code that only runs in local testing; our production implementation of alarms is very different. Separately, though, I think I did hear someone say something about fixing a bug which had caused some alarms to fail to run, and that old alarms might start running as a result. I don't personally know the details of this. Maybe ask in the Durable Objects room on Discord? |
Ah ok thanks, got a response a few days ago there:
|
Sometimes when I schedule alarms in a Durable Object, I get the following error:
I tried looking through the source code, but it’s very hard to determine why this is occurring,
especially because I don’t think KJ is open source. The behaviour appears inconsistently (restarting usually fixes it), but if it helps the kinds of calls I’m making are:Temporal.Now.instant()
, which usesDate.now()
under the hood)For both, I sometimes check for the presence of an existing alarm first, but not always. Any hints?
The text was updated successfully, but these errors were encountered: