15 Replies
1984 Ford Laser
1984 Ford Laser7mo ago
I was just reading this article from a year ago regarding the availability of WebGPU in Workers: https://blog.cloudflare.com/webgpu-in-workers/ The article mentions needing to use DOs to work with WebGPU. Has anyone had any success with using WebGPU since that article, as it seemed like things were very much stil happening when it was published. I have a use case for transcoding short videos on demand with a quick turn around, and was wondering if this might be the path forward, as there doesn't seem to me much info in this space
The Cloudflare Blog
You can now use WebGPU in Cloudflare Workers
Today, we are introducing WebGPU support to Cloudflare Workers. This blog will explain why it's important, why we did it, how you can use it, and what comes next.
1984 Ford Laser
1984 Ford Laser7mo ago
Thats what I thought, I had seen that mention of local dev only a few times. I haven't yet tried to transcode video using workers, just wasn't sure if I was missing some obvious solution. Thanks for the info
Abakir
Abakir7mo ago
When you push a worker to production do alarms set before get deleted?
Unsmart
Unsmart7mo ago
No, alarms are durable
Isaac McFadyen
Isaac McFadyen7mo ago
^ durable = they persist just like storage does, even across redeploys
egg
egg7mo ago
Am I doing something wrong here? I'm trying to close a websocket immediately. Would prefer to have instant closure.
#reject_websocket(code?: number, reason?: string) {
let { 0: webSocket, 1: server } = new WebSocketPair()

server.accept() // Always throws Error: Network connection lost. Uncatchable
// vs
this.ctx.acceptWebSocket(server) // Does not throw but causes ~2 second delay to close ws.

server.close(code, reason)

return new cf_global.Response(null, {
status: 101,
webSocket,
})
}
#reject_websocket(code?: number, reason?: string) {
let { 0: webSocket, 1: server } = new WebSocketPair()

server.accept() // Always throws Error: Network connection lost. Uncatchable
// vs
this.ctx.acceptWebSocket(server) // Does not throw but causes ~2 second delay to close ws.

server.close(code, reason)

return new cf_global.Response(null, {
status: 101,
webSocket,
})
}
_.Mass._
_.Mass._7mo ago
Hi, I am using a hibernatable websocket connection in a Durable Object. During a webSocketEvent of type message I am accessing the DO transactional storage and I am seeing some Range exceptions caused by exceeding the storage size limit for value. I am expecting the webSocketError event to be called for those kind of errors according to what the docs are stating https://developers.cloudflare.com/durable-objects/api/websockets/#websocketerror. Is a Range exception triggering a webSocketError event? I am able to catch the error with a try and catch. I thought thought I could handle all errors in the webSocketError event handler
Milan
Milan7mo ago
webSocketError() would run if something broke on the WebSocket, not if your application code threw an exception. If you're just calling a func/method that can throw and you want to handle exceptions you should wrap it in a try...catch
_.Mass._
_.Mass._7mo ago
Thank you for the clarification 👍
Milan
Milan7mo ago
No prob!
Avi
Avi7mo ago
>"The Durable Object's code has been updated, this version can no longer access storage." How can this happen if we dont deploy a new version? separate question: is there a suggested pattern for setting a TTL on durableobject storage? e.g. "clear after 1 hour?" alarms?
Isaac McFadyen
Isaac McFadyen7mo ago
Likely a runtime update (meaning the runtime, workerd, or the underlying storage that backs Durable Objects).
Chaika
Chaika7mo ago
could also be caused by tailing
euan
euan7mo ago
So Sqlite durable objects Vs D1. When does this change the decision matrix to use one or the other? JSON blobs?
Isaac McFadyen
Isaac McFadyen7mo ago
DO SQLite is more of a lower level primitive that you can use to build your own solution. It's missing most of the things that D1 does/will eventually bring like replication, any cross-DB querying, etc. If you wanted to build the next D1: use DO SQLite, but if you just want a database you can easily access and query from Workers or the Cloudflare API then use D1. Also DO SQLite has lower limits currently.

Did you find this page helpful?