-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add timeout when making requests to Uplink #1950
Conversation
It's an internal function, it's OK to make it newly required
- Use `onRetry` synchronously - Set a `maxTimeout` since the current default is `Infinity` - Remove `earliestFetchTime` because it wasn't doing what we thought and it's not super helpful in a datetime format when we already have a similar notion as an absolute delay in ms. - Add logging
✅ Deploy Preview for apollo-federation-docs canceled.
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
It makes types show up better in my editor
I don't think we want to give this power to everyone
Our `FetcherRequestInit` type doesn't include `timeout` (though most implementations support that). There's also `signal` that `node-fetch` supports and is in the `minipass-fetch` API (the library the underlies `make-fetch-happen`), but the types aren't updated correctly. Rather than dealing with either of these things directly, I'm just adding locally for now. In general, we may not want to allow users to pass in a custom fetcher for Uplink anyway.
Trying to keep the number of random exports we have down, so exposing default uplink info via the `UplinkSupergraphManager` class makes most sense
- Consolidate `fallbackPollIntervalMs` and `minDelayMs` into `pollIntervalMs` in `UplinkSupergraphManager` - Set `pollIntervalMs` in `updateSupergraphSdl`, since that's needed both during init and during polling - Moved checking `pollIntervalMs` out of the main gateway code so that more Uplink logic can live in `UplinkSupergraphManager`
Add `AbortableFetcher` and its ilk to support a `Fetcher` that also has a `signal` field, which is used implement the timeout pattern in standard web `fetch`. This also adds a `requestTimeout` property to `UplinkSupergraphManager`, though I didn't expose it in the constructor because I'm not sure if that's a knob we want to expose yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a quick look. I realise that I really don't know these parts of the code and would need more time to understand this better, but didn't saw anything wrong and the reasonings make sense to me.
We can technically still set property values, but TS will complain. We can abuse that functionality to make our tests behave like we want. This is better than special-casing the value so users don't accidentally get lower values in their test environments.
I think we'll get less test cross-talk this way
This is a series of changes that will hopefully fix or shed light on why we've gotten several reports of "gateway stops polling Uplink".
fallbackPollIntervalMs
andearliestFetchDate
intopollIntervalMs
inUplinkSupergraphManager
. This makes the code easier to follow, and simplifies where and how we setUplinkSupergraphManager.pollIntervalMs
.async-retry.onRetry
asynchronously because that function is called synchronously, and was resulting in some odd behavior.pollIntervalMs
asminTimeout
, so that defaults to 1000msmaxTimeout
to 60_000 ms so we'll never reach the default Infinity (maxRetries
would have to be set very high to reach Infinity, but this is a safer option)node-retry
library to set time between retries.