abort `"user server"` function call
is it possible to abort a call to a
"use server"
function? behind the scenes they're just fetch()
es right? if so is there some way to pass though an abort signal?
thanks.6 Replies
https://discord.com/channels/722131463138705510/780502110772658196/1268618927387181168
Even if you go ahead an create an API Route and use an abort controller client side, you're still going to have to dig deep into the server platform's
request
to listen to the request closing (which happens right after an abort)
https://nodejs.org/api/http.html#http_event_close_3
to be able to catch the abort and then stop processing on the server side.I'm just using the self hosted node platform
Event Object - h3
Event object carries an incoming request and context.
GitHub
solid-start/packages/start/src/server/types.ts at dbfc569e38e7c3494...
SolidStart, the Solid app framework. Contribute to solidjs/solid-start development by creating an account on GitHub.
so does this mean I can't use
"use server"
?Not if you want to use abort. RPC abstractions often don't expose a way to cancel and even abort is largely about the client side behaviour of
fetch
. Typically server code has to go out of its way to detect abort
. In many cases the request just runs to completion and the finished response is ignored by the client.MDN Web Docs
AbortController: abort() method - Web APIs | MDN
The abort() method of the AbortController interface aborts an asynchronous operation before it has completed.
This is able to abort fetch requests, the consumption of any response bodies, or streams.
FYI: To Seroval's credit you can successfully pass a promise from the client to the 'use server' section via action parameters. But it cannot be used to trigger an abort as the 'use server' section doesn't start running until the inbound promise has settled.