IIRC there is no way to launch a promise

IIRC there is no way to launch a promise in a durable object (from a request) in such a way that does not block a response? For example I am trying to ship logs from a custom logger async to loki, but i don't want that to block responding to a request
D
DanTheGoodman237d ago
bascially .waitUntil but for DOs
S
sathoro237d ago
I think if you just call the promise and don't await it, it will still get processed in the background for up to 1 minute
D
DanTheGoodman237d ago
but it blocks the response to the client though
UU
Unknown User237d ago
K
kenton237d ago
It shouldn't, if you don't await it.
D
DanTheGoodman237d ago
I though the output gate would block it… and it still will complete in the background before sleeping a do?
K
kenton237d ago
the output gate only blocks waiting for storage writes to hit disk; it doesn't wait for network requests
D
DanTheGoodman237d ago
Awesome, but any running promises will resolve before the DO gets potentially unloaded? Well exit not necessarily resolve
K
kenton237d ago
(and FWIW the output gate will actually block both responses and outgoing fetch()es, until all writes are durable) The DO will will wait at least 30 seconds (actually 70 seconds) for remaining I/O after the last client disconnects essentially it automatically does waitUntil which is why we removed the explicit waitUntil API
D
DanTheGoodman237d ago
but it can be longer if the promise is still running?
K
kenton237d ago
if there is still a client waiting for a response, the DO will not be evicted at all (well, unless hibernation is enabled for that request/response)
D
DanTheGoodman237d ago
I'm thining more in the scenario where I do like:
storage.put()
sendLogsToLoki() // promise
return new Response()
storage.put()
sendLogsToLoki() // promise
return new Response()
where the sendLogsToLoki is a promise that does not block the client getting a response, but the DO wont unload until that promise resolves so in theory the client could be disconnected already while that promise is still running due to retries or what ever I think that's safe based on what's explained above? And that the sendLogsToLoki promise wont block the client from getting the response
K
kenton237d ago
the DO will be evicted some time after the last client disconnects, even if there are outgoing requests still in flight. Those requests will be canceled.
D
DanTheGoodman237d ago
gotcha, thanks for clarifying
K
kenton237d ago
it's the same with waitUntil() BTW -- it has a 30-second limit
Want results from more Discord servers?
Add your server
More Posts
308 for newly bought domainHey, I just bought a domain on cloudfare : https://citeasy.app However, I can't seem to access it. soketiCan someone help me understand costs associated with using workers for websockets? I'm specificallynodejs_compat compatibility-flags flags not working for Pages functionsI've added nodejs_compat to both prod and preview in the UI but every deploy fails with these errorsworker to allow web scrape by friendly bot?I'm using an AI app called Mendable to scrape my own website for training. CF is blocking their scrarpat not found (Code: 10003) , How to solve the problem ?The website was infected some time ago, the problem was fixed, but when I click the request review bPort redirectionIs there any means to reroute requests to a different port based on e.g, hostname? For example this Small error in the worker-tail documentationI don't think it should say `index.js` when it's showing a JSON in the documentation for worker-tailSveltekit + Cloudflare Pages + ResendHello! I've been banging my head against a wall as i don't know how to go about finding out whats wrconnect to hibernatable websocket,then how to send the Offline messages to the clientI use the warn method,but it doesn’t Passing parameters,I think it should be had a webSocketOpen metI get the error just when starting devI get the error just when starting dev mode no requests made. Let me start a thread with the code peExecuting Deployments in Workers via HTTP Requests Post-Content UpdateIs it possible to execute a deployment by sending an HTTP request to Workers when updating content fWHIP Camera streamHi all, I am trying to test WHIP on Cloudflare using OBS for now. However, I have had no luck gettiHTTP ERROR 404Does this mean the cloudfared servers are down or having issues?Cloudflare URL mappingHello 🖐️ For example in Cloudflare: I have https://example.com/assets/image/keepcalm.jpg and I waWorker using fetch gets 522 from CF Pages ProjectHere is my problem. User hits my pages website (origin), the javascript that is loaded hits the pageR2.dev subdomain has been set to 'allow' status. But when open the link, it showed Error 404."Error 404 This object could not be viewed You are not authorized to view this object This object dPages function not binding to workerI am trying to use a service binding to bind my page "function" to a worker. When calling `env.myotWhat's the appropriate typescript type (within Env) for a binding to another worker?For instance, for a durable object it would be: ``` interface Env { MY_DO: DurableObjectNamespaceHi guys, I have changed the A record to point back to hosting, but the error page is being displayedWhat can be a cause of this, hostinger said that not pointing correctly back to ip 403 Forbidden Ac`Reflect.get called on non-object` error when using OpenAI library in NextJSI'm having issues in getting OpenAI library to work in NextJS project on Cloudflare Pages. I got the