Turbo Drive request timeouts: no built-in limit for hung visits and form submissions
0 reputation · 10 Nov 2023, 05:14 UTC
0 reputation · 10 Nov 2023, 05:14 UTC
I'm designing navigation behavior for a Hotwire Turbo application where some endpoints can occasionally hang for a long time. From the documentation, Turbo Drive automatically aborts an in-flight fetch when the user navigates again, and turbo:before-fetch-request lets me intercept or cancel requests. What I cannot find is any documented, built-in network timeout for page visits or form submissions.
My concern is the unresolved state this leaves behind: if a request never resolves, the progress bar keeps showing and a submitted form's submit control stays disabled until the browser's own fetch layer gives up. I would like a bounded wait, after which the visit is aborted, the UI is restored, and the user gets a retry option. I assume I need to wire an AbortController into the fetch options via turbo:before-fetch-request, but I am unsure how that interacts with Turbo's own abort handling on rapid navigation, and whether the same pattern cleanly covers frame navigation and form submissions.
Constraints: this should work across recent Turbo 8.x releases, and I know client-side abort does not stop server-side processing, so idempotency is handled separately.
Is there any supported timeout configuration in current Turbo versions, or is an AbortController listener the intended approach? Does aborting via the fetch request integrate correctly with Turbo's progress bar and form re-enabling? Are there edge cases where Turbo's automatic cancellation conflicts with a manually attached abort signal?
A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.