Justin
Justin
CDCloudflare Developers
Created by Tilon on 4/6/2024 in #workers-discussions
Hi, I am using the new RPC service
I think it has something to do with the calling Worker's execution ending before the DurObj (in my case) ends as per the docs: "A Worker invoked via RPC also has an execution context. The context begins when an RPC method on a WorkerEntrypoint is invoked. If no stubs are passed in the parameters or results of this RPC, the context ends (the event is “done”) when the RPC returns. However, if any stubs are passed, then the execution context is implicitly extended until all such stubs are disposed (and all calls made through them have returned). As with HTTP, if the client disconnects, the server’s execution context is canceled immediately, regardless of whether stubs still exist. A client that is itself another Worker is considered to have disconnected when its own execution context ends. Again, the context can be extended with ctx.waitUntil()."
11 replies
CDCloudflare Developers
Created by Tilon on 4/6/2024 in #workers-discussions
Hi, I am using the new RPC service
I'm seeing the same thing. Functionally everything seems to work as expected, but the "outcome: canceled" logs are disconcerting. In my case I have a really simple Durable Object defined:
import { DurableObject } from 'cloudflare:workers'

export class ZoneState extends DurableObject {
async getState() {
return { test: "testing" }
}
}
import { DurableObject } from 'cloudflare:workers'

export class ZoneState extends DurableObject {
async getState() {
return { test: "testing" }
}
}
Being called by a super simple Worker that's consuming a queue:
export default {
async queue(batch: MessageBatch, env: Env): Promise<void> {
const zoneStateDurObj = env.ZONE_STATE.get(env.ZONE_STATE.idFromName('milldistrict'))
const state = await zoneStateDurObj.getState()
console.log(JSON.stringify(state))
},
}
export default {
async queue(batch: MessageBatch, env: Env): Promise<void> {
const zoneStateDurObj = env.ZONE_STATE.get(env.ZONE_STATE.idFromName('milldistrict'))
const state = await zoneStateDurObj.getState()
console.log(JSON.stringify(state))
},
}
I get the JSON object from the DurObj and it's logged as expected, but I also get a log like:
{
"outcome": "canceled",
"scriptVersion": {
"id": "eda5fc7a-50c7-4d30-82b4-29e975cc23c4"
},
"entrypoint": "ZoneState",
"scriptName": "zone-state-development",
"diagnosticsChannelEvents": [],
"exceptions": [],
"logs": [],
"eventTimestamp": 1712840487484,
"event": {
"rpcMethod": "getState"
},
"id": 3
}
{
"outcome": "canceled",
"scriptVersion": {
"id": "eda5fc7a-50c7-4d30-82b4-29e975cc23c4"
},
"entrypoint": "ZoneState",
"scriptName": "zone-state-development",
"diagnosticsChannelEvents": [],
"exceptions": [],
"logs": [],
"eventTimestamp": 1712840487484,
"event": {
"rpcMethod": "getState"
},
"id": 3
}
The workaround of passing a function won't work for me as I need to actually work with storage in the DurObj. Any further thoughts on what might be going on here would be most appreciated!
11 replies