Comments (6)
Apollo Client with the HttpLink just calls fetch
, which does not have a timeout option.
It will try to wait until the server closes the connection, so it's literally impossible to increase the timeout on client side any further than that.
You could shorten the waiting time by introducing your own link to the link chain that would time out requests after a while, but making requests last longer than they currently do is just not possible as they already wait the maximum possible amount of time.
from apollo-client.
@phryneas fetch
allows to cancel an inflight requests through the AbortController
signal.
Current browsers support a shortcut through AbortSignal.timeout
, like:
async function loadPosts() {
try {
const response = await fetch('/posts', {
signal: AbortSignal.timeout(5000)
});
const posts = await response.json();
return posts;
} catch (error) {
// Timeouts if the request takes longer than 5 seconds
console.log(error.name === 'AbortError');
// handle error
}
}
This use case is quite common to ensure the server, or the overall network latency is holding the response for a long period of time.
Considering Apollo Client uses a fetch interface, it would be appropriate to have this option available from Apollo Client directly. Right now the only way possible is to create a custom HttpLink
with the custom logic. Not a hard task, but is a bit tedious for such a basic functionality.
from apollo-client.
@lughino I'm not sure if this is the right issue to ask for this.
This issue was not asking for a timeout
option, but it was asking for a way to increase an assumed existing timeout (which doesn't exist).
Generally, I agree, that we could introduce timeout
option, but that should probably be tracked in a separate issue over in https://github.com/apollographql/apollo-feature-requests.
Could you please open an issue over there?
from apollo-client.
Sure thing @phryneas I'll open a issue there
from apollo-client.
Thank you!
I believe I can close this issue here then, since @jeebeez never answered - I assume the explanation I gave in my first answer was probably enough.
from apollo-client.
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.
from apollo-client.
Related Issues (20)
- refetch from useSuspenseQuery doesn`t return the updated data with fetchPolicy: 'cache-first' HOT 3
- Issue with useSuspenseQuery in Next.js Client Component: Duplicate Queries on Server and Client HOT 6
- @client on arguments HOT 9
- [Docs] Add some documentation on how to test `preloadQuery`
- [Data masking] Provide testing utility to provide proper format to `from` option in `useFragment`
- Typescript error with RequestInfo HOT 4
- Paginated read functions is not returning updated args when using fetchMore HOT 1
- [Testing utilities] Allow passing a seed to `createMockSchema` HOT 3
- is there is any library in react-native that will work like if api post request fails so it will save in own cache and when it will get internet then it will post it HOT 3
- useApolloClient hook return type HOT 4
- [Testing utilities] Add min/max thresholds to options accepted by createMockFetch HOT 3
- Polling does not stop after unmounting query HOT 2
- [bug?] refetch() resolves to undefined after component is unmounted
- [Testing utilities] Support merging resolvers HOT 2
- Regression in 3.9.5 with cache updates and error responses HOT 3
- on error ReferenceError: WebSocket is not defined HOT 5
- Implement Server-Side Pagination in Next.js with Apollo Client HOT 2
- useSuspenseQuery with skipToken still issues network request HOT 7
- 3.9.7 switching fetch in HttpLink to Axios triples speed HOT 7
- When using `useReadQuery` directly before `useQueryRefHandlers`, `refetch` won't update the `useReadQuery` result HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo-client.