workerd: š Bug Report ā Runtime APIs: `alarm-scheduler` fails for inscrutable reason
Sometimes when I schedule alarms in a Durable Object, I get the following error:
workerd/server/alarm-scheduler.c++:203: warning: exception = kj/filesystem.c++:304: failed: expected strlen(part.begin()) == part.size() [6 == 71]; NUL character in path component; part = ��zUdc5238b9�$�v$7559429.sqlite
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:
- Schedule around 500ms in the future
- Schedule at the current date (via
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?
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Reactions: 5
- Comments: 16 (7 by maintainers)
Commits related to this issue
- Attach the kj::Path in alarm-scheduler.c++ This is an attempt to fix https://github.com/cloudflare/workerd/issues/1386 — committed to cloudflare/workerd by jasnell 7 months ago
- Persist the actorId for ActorSqliteHooks Fixes: https://github.com/cloudflare/workerd/issues/1386 — committed to cloudflare/workerd by jasnell 7 months ago
Okay, I have a reproduction!
Use the code from above:
index.ts:wrangler.toml:.vscode/launch.json:Iāve only reproduced in VS Code. The steps are:
console.logline)wrangler devcurl localhost:8787I 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
workerdbranch and host it insideminiflareinsidewranglerbut if you need me to do it I could give it a crack.I just looked quickly at alarm-scheduler.c++ and thereās currently only one place weāre passing along a
kj::PathPtrthat could potentially be a problem here. I just opened https://github.com/cloudflare/workerd/pull/1442 that ensures thekj::Pathis attached and kept alive. I havenāt reproād the actual segfault locally yet so it would be helpful if someone who has reproād it could give the potential fix in #1442 a try.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
workerd/wrangleris calling that deep into the stack without a useful stack trace, which Iām not getting (mine just spits out anLLVM_SYMBOLIZERerror a la cloudflare/workers-sdk#3631). I would love to debug this myself but itās just too hard. Should I move this toworkers-sdk?