Turbo Drive 2.0: Should a Global Timeout Configuration Be Added?
0 reputation · 25 Jul 2021, 21:09 UTC
Developers using Turbo Drive often need to limit how long a page visit can wait for a server response, especially when dealing with unreliable backends or long‑running endpoints.
The current implementation relies on the Fetch API and provides no default timeout; a visit proceeds until the network layer signals failure or the server replies. To impose a limit, one must listen to turbo:before-fetch-request, create an AbortController, and tie a setTimeout to abort the request, as shown in the official documentation.
This manual approach raises concerns about boilerplate, potential memory leaks if controllers are not cleaned up, and the lack of a centralized configuration that could be versioned or overridden per environment.
What are the trade‑offs of adding a timeout option to Turbo Drive’s configuration? How would it interact with existing turbo:before-fetch-request and turbo:visit‑cancelled events? Should the timeout be defined globally, per‑visit, or scoped to specific frames?