cloudflare / cloudflare/workerd

🐛 Bug Report — Runtime APIs: `setAlarm` throws `tried to arm Event after it was destroyed`

Open
#1,272 0 comments 1 reaction 0 assignees View on GitHub
Durable Objects
Dominant language
C++
Stars
8.7k
Forks
739
Avg merge
2d 20h
Merged PRs (30d)
174

Description

I'm having trouble using `state.setAlarm`.

Given the following config file `config.capnp`:

```capnp
using Workerd = import "/workerd/workerd.capnp";

const config :Workerd.Config = (
services = [(name = "worker", worker = .worker)],
sockets = [(name = "http", address = "*:80", service = "worker")]
);

const worker :Workerd.Worker = (
compatibilityDate = "2023-09-18",
modules = [(esModule = embed "worker.js")],
durableObjectStorage = (inMemory = void),
durableObjectNamespaces = [(className = "DO", uniqueKey = "")],
bindings = [(name = "dos", durableObjectNamespace = "DO")]
);
```

and the following root module `worker.js`:

```js
export default {
async fetch(request, env) {
return env.dos.get(env.dos.newUniqueId()).fetch(request)
}
}

export class DO {
constructor(state, env) {
this.state = state
}

async alarm() {}

async fetch(request) {
this.state.storage.setAlarm(Date.now() + 1000)
return new Response('ok')
}
}
```

then running the following from the command line:

```sh
workerd serve --verbose --watch config.capnp
```

and accessing `http://localhost`, the server returns 200, but process crashes a second later with the following output:

```
workerd/util/symbolizer.c++:98: warning: Not symbolizing stack traces because $LLVM_SYMBOLIZER is not set. To symbolize stack traces, set $LLVM_SYMBOLIZER to the location of the llvm-symbolizer binary. When running tests under bazel, use `--test_env=LLVM_SYMBOLIZER=`.
*** Fatal uncaught kj::Exception: kj/async.c++:2188: failed: tried to arm Event after it was destroyed; location = src/workerd/io/worker-entrypoint.c++:379:61 in runAlarmImpl
stack: 1046f0d5b 1046f1283 1046f237f 1046f93eb 1046f03bf 102920d27 102924313 10292414f 102924137 1047596f3 104759a3b 10475819b 104757f6b 1029181af 18af25057
make: *** [serve] Error 1
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.