websocket abruptly closes
I'm using MS cognitive services with CloudFlare Pages and the websocket connection closes before covnerting text to audio and generting the file:
I got this error:
My understanding is that
WaitUntil
kept the task running in the background until completion. Why then does the ws end before completion? How can I keep running in the background? (I'm in Unbound mode)8 Replies
Converting text to audio sounds like an arduous task. You might be hitting other limits (e.g. the 128 MB memory limit). I'd advise that you try this first outside of a
waitUntil
, just to see if it's possible, and only then try actually putting it into a waitUntil
.
waitUntil itself is a best-effort mechanism. There are no guarantees that the work will definitely be completed@veerooo What do you mean by 'arduous task'? this is done at MS servers.
The point is that it takes a while to get the response (from my experience doing the convertion using Remix with Node.js). I mean, it worked for me using node.js ... so the point is I don't know how to make it work with Workers because the connections is closed.
I tried without
waitUntil
and it didn't work . But what do you mean? drop waitUntil
and use and standard promise await
?Yeah, drop the
waitUntil
and just await it before returning any response, just to see if it's even possible in Workers. We don't have perfect compatibility with Node.js (we run in a v8 environment), so it's possible that this requires a bit of tweaking (or it may be downright impossible). The team is suggesting to start with the simplest possible version of the code to see how that works, and then optimize by pulling out into waitUntil
etc.@Vero
With a promise the result it's even worse:"
I opend this issue with MS , and they fixed the code to allow user Workers (V8)
https://github.com/microsoft/cognitive-services-speech-sdk-js/issues/645
GitHub
SDK with Cloudflare workers and Fetch API · Issue #645 · microsoft/...
When using this sdk with cloudflare workers I get this error: XMLHttpRequest is not defined I understand it's due to t...
What I don't understand it's why the connection is dropped when I'm in Unbound mode and supposedly there's 30 sec to execute, right?
According to MS, on their side it's ok (see the last comment)
And there's another issue: apparently I can only test it in prod because MS's sdk only works with
wss
and miniflare apparently only support ws
(
@veerooo any suggestion on what to do? Using a promise apparently it doesn't await to the response ...I know this is 6+ months old, but if anyone else is coming up against this, it seems to be an issue with Cloudflare workerd. https://github.com/cloudflare/workerd/issues/1370#issuecomment-1859447303
GitHub
🐛 Bug Report — Runtime APIs: names of WebSocket ready state consta...
Names of ready states constants on the WebSocket class, defined in here differ from that of the Web IDL definition in the WebSocket Living Standard. In workerd, every name have extra prefix: READY_...
There's an open PR so hopefully should be fixed soon but I've also mentioned a temporary workaround in case you need it beforehand