qwik icon indicating copy to clipboard operation
qwik copied to clipboard

[📖] Add docs about `AbortSignal` in `server$` API

Open aivarsliepa opened this issue 3 years ago • 4 comments

Suggestion

#4214 added support for AbortSignal in server$ API However, it's undocumented and not that clear how to use it. server$ - streaming responses seems like a good place where to add docs for this feature.

aivarsliepa avatar May 19 '23 09:05 aivarsliepa

@DanielAdolfsson since you were the author of this feature, would you be willing to add docs?

aivarsliepa avatar May 19 '23 09:05 aivarsliepa

Sure, I can do that! But it seems like it's still up in the air - got a suggestion to change the API to return a cancelable promise instead of passing an AbortSignal. Once that's been cleared up, I'll update the docs.

DanielAdolfsson avatar May 19 '23 09:05 DanielAdolfsson

thanks @DanielAdolfsson for taking this over 🙏

zanettin avatar May 19 '23 19:05 zanettin

~~The AbortSignal implementation was a bit hacky, and it could only effectively be used to cancel long running async generators. #4290 reverts the AbortSignal change and instead focuses on proper async generator cleanup, meaning that the connection will end if the client breaks out from the generator loop (or otherwise call return() on the async generator). Is this something I should mention in the docs?~~

Removing the AbortSignal signature just makes is harder. I'd have to implement an CancellablePromise, as well as a CancellableAsyncGenerator. It felt a bit hacky, but I think it's probably better to keep it for now.

DanielAdolfsson avatar May 22 '23 13:05 DanielAdolfsson