All questions

What is the default content fetch timeout in the React SDK and can I tighten it?

Asked by sam.frontend on

Ssam.frontend

Testing on a throttled connection I noticed a content fetch hang for what felt like several seconds before teh fallback kicked in. I would rather it give up sooner and show the default fast on a bad network.

What timeout does the React SDK use by default, and can I shorten it?

Was this helpful?

1 answer

Ddermot_k

The browser plug defaults to a 5000ms fetch timeout, which is what you were watching wait out. (For reference the Next.js default is lower, 2000ms.) You change it with defaultFetchTimeout at initialization on the provider:

<CroctProvider appId="..." defaultFetchTimeout={1500}>    <App /></CroctProvider>

Pair a shorter timeout with a fallback on the fetch, so when it does time out the region still renders default content instead of nothing. Keep in mind end-to-end response times are under 90 milliseconds at P95, so the timeout is a safety net for bad networks, not the normal path. A very tight timeout mostly changes how fast you give up on the unhappy case.

Was this helpful?
Ssam.frontend

Dropped it to 1500 with a fallback, the slow-network case shows the default almost immediately now. Thanks.

Still have questions?