vans163
04/15/2021, 11:29 PMjavascript
class User {
async job_new_transcode(request) {
const json = await request.json();
var {now, uuid} = uuid32hex();
const job = {
uuid: uuid,
}
await this.storage.put(`job:${uuid}`, job)
this.broadcast_new_job(job)
return new Response(JSON.stringify({error: "ok", uuid: uuid}), REPLY);
}
broadcast_new_job(job) {
this.sessions.forEach(session => {
if (session.this_does_not_exist.crash) {
}
})
}
}
if broadcast_new_job is made async, and we dont await the call. It still crashed but no error is reported. In both cases the DO does not stop running.vans163
04/16/2021, 3:20 AMvans163
04/16/2021, 3:20 AMvans163
04/16/2021, 3:21 AMvans163
04/16/2021, 3:21 AMvans163
04/16/2021, 3:21 AMDeleted User
04/16/2021, 3:49 AMjonas
04/16/2021, 4:36 AMundefined
back. I had this working prior to testing out durable objects and usually it worked just fineGrygrFlzr
04/16/2021, 4:38 AMenv
in a durable object
> js
> // In modules-syntax workers, bindings are delivered as a property of the
> // environment object passed as the second parameter when an event handler or
> // class constructor is invoked. This is new compared to pre-module workers,
> // in which bindings show up as global variables.
>
jonas
04/16/2021, 4:44 AMconstructor
part then to declare it?GrygrFlzr
04/16/2021, 4:45 AMGrygrFlzr
04/16/2021, 4:45 AMGrygrFlzr
04/16/2021, 4:45 AMGrygrFlzr
04/16/2021, 4:45 AMjonas
04/16/2021, 4:47 AMGreg-McKeon
04/16/2021, 6:54 AMvans163
04/16/2021, 9:20 AMvans163
04/16/2021, 9:25 AMBienvenu
04/16/2021, 11:57 AMBienvenu
04/16/2021, 11:59 AMeidam | SuperSaaS
04/16/2021, 12:03 PMdbingel
04/16/2021, 12:30 PMtypescript
async handleRequest(request: Request, env: DurableObjectEntries<DurableObjectNamespace>) {
const id = env.COUNTER.idFromName('Foo');
// ...
}
or
typescript
interface Environment {
[key: string]: DurableObjectNamespace
}
async handleRequest(request: Request, env: Environment) {
const id = env.COUNTER.idFromName('Foo');
// ...
}
? Is the interface DurableObjectEntries
intended for this use case at all?Electroid
04/16/2021, 12:47 PMEnvironment
or Env
interface, because you might want other bindings eventually. Like an actual env variable or a KV namespacevans163
04/16/2021, 2:05 PMvans163
04/16/2021, 2:05 PMTill
04/16/2021, 4:33 PMTill
04/16/2021, 4:33 PMevent
in there?Till
04/16/2021, 4:34 PMrespondWith
with event
.Deleted User
04/16/2021, 4:55 PM