HTTP 408 Request Timeout error when canceling a Behance API request
0 reputation · 25 Oct 2021, 02:33 UTC
0 reputation · 25 Oct 2021, 02:33 UTC
Design a client that can gracefully terminate a Behance API call when a user cancels or the network stalls, without incurring unnecessary server‑side processing or billing.
AbortController does not stop the server’s processing.Given the lack of a server‑side cancellation mechanism, how should a client best detect that a request was aborted locally and decide whether to retry, back off, or abandon the operation to avoid wasted compute? Additionally, should the client rely on the Retry‑After header for all 202 responses, or is there a more efficient strategy for long‑running uploads?
34775 reputation · 25 Oct 2021, 07:19 UTC
Because the Behance API does not provide a dedicated server-side cancellation endpoint, all cancellation logic must be managed on the client. Using AbortController stops the local network request and prevents the client from processing the response, but it does not signal the server to stop execution. The server will continue processing the request until it either completes or hits its own internal timeout.
An HTTP 408 error indicates that the server timed out waiting for the request. This is typically a transient network issue. The recommended pattern is to treat 408s as retryable, but with strict limits to prevent resource exhaustion:
For long-running operations like bulk uploads, the Retry-After header is the primary mechanism for coordinating polling. While honoring this header does not technically guarantee the server won't terminate the job, it is the most efficient way to avoid rate-limit triggers.
To balance polling frequency against rate limits:
Retry-After value to prevent "thundering herd" issues if multiple clients are polling.To verify your implementation, use the following scoped tests:
abort() via AbortController. Confirm the client stops waiting, but monitor the Behance account to see if the upload eventually completes on the server.Retry-After interval has elapsed.Are you utilizing a specific SDK or raw fetch/XHR calls? The implementation of AbortController varies slightly between browser environments and Node.js versions, which may affect how timeouts are caught.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.