Cancel HTTP requests initiated by a transport #1701
Replies: 5 comments 5 replies
-
Just commenting that this would be used in Wagmi too (have a TODO over there). Need to figure out a good API. |
Beta Was this translation helpful? Give feedback.
-
Couple quick ideas:
export type EIP1193RequestOptions = {
// The base delay (in ms) between retries.
retryDelay?: number
// The max number of times to retry.
retryCount?: number
+ // An AbortSignal to be used by interruptible operations made during the request (e.g. `fetch`).
+ signal?: AbortSignal
}
|
Beta Was this translation helpful? Give feedback.
-
I'm glad this is getting tackled. I closed #1239 as a duplicate. This would be really handy to embed viem fully into the Effect interruption model :-) |
Beta Was this translation helpful? Give feedback.
-
how can I find out the latest status of this feature, such as the expected release date? |
Beta Was this translation helpful? Give feedback.
-
It would be great to programmatically cancel in-flight HTTP (or WebSocket) requests initiated by a transport. Best case, we could cancel individual requests, but it would still be very useful if it were only at the transport level (effectively a "shutdown"/cleanup function for the transport).
I experimented with passing an
AbortSignal
to thehttp
transportfetchOptions
. This seems to work, but it looks like providing this option disables the timeout logic. This could probably be fixed usingAbortSignal.any()
. But, this would only work for HTTP transports and only at the transport granularity, not for individual requests.Beta Was this translation helpful? Give feedback.
All reactions