fix(plugin-typescript): add a timeout to the Algolia auto-types lookup#7206
Open
sebdanielsson wants to merge 1 commit into
Open
fix(plugin-typescript): add a timeout to the Algolia auto-types lookup#7206sebdanielsson wants to merge 1 commit into
sebdanielsson wants to merge 1 commit into
Conversation
`yarn add` queries Algolia's `npm-search` index to detect whether the added package needs a matching `@types` package. On restricted networks (eg. a corporate proxy that drops or refuses the request) this lookup had no timeout and could make `yarn add` hang indefinitely, while `yarn install` kept working against the configured registry. This caps the lookup at 10s and, on timeout or network failure, warns the user (pointing at the `tsEnableAutoTypes: false` / `YARN_TS_ENABLE_AUTO_TYPES="false"` escape hatch) before letting the install proceed without the `@types` package. It also hardens the Algolia requester so a connection error without a `response` no longer throws an unrelated `TypeError`. Closes yarnpkg#7111 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NS1JKnVAz9uPwdyUhfub2g
Author
|
CI failures seem to be pre-existing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's the problem this PR addresses?
Closes #7111
yarn addqueries Algolia'snpm-searchindex to detect whether the added package needs a matching@typespackage. In our corporate network, all egress traffic traverses our HTTP proxy. If this is set globally usingHTTPS_PROXY,HTTP_PROXY, andNO_PROXY, but not explicitly with Yarn's HTTP proxy config, this query will not go through the proxy but will instead try to make a direct connection. In our case, this means the firewall silently drops the connection.httpTimeoutis not what's bounding a single attempt. I dropped it from 15s to 10s and got an identical ~135s per attempt. The wait is the Linux kernel's TCP SYN-retry exhaustion (default tcp_syn_retries=6, ~127–135s in my tests). Because the TCP socket never establishes, got's timeout.socket (which is socket-inactivity-after-connect) never starts. Got then retries httpRetry times, which multiplies the dead time.My tests:
httpTimeout=10s httpRetry=0httpTimeout=10s httpRetry=1httpTimeout=15s httpRetry=1httpTimeout=1m httpRetry=3)How did you fix it?
This caps the lookup at 10s and, on timeout or network failure, warns the user (pointing at the
tsEnableAutoTypes: false/YARN_TS_ENABLE_AUTO_TYPES="false"escape hatch) before letting the install proceed without the@typespackage. It also hardens the Algolia requester so a connection error without aresponseno longer throws an unrelatedTypeError.Future fixes
My last comment in the linked issue proposes additional fixes to make this more stable, but I wanted to keep this PR small and easy to review. A future enhancement would be to have the Algolia lookup respect the global HTTP environments, just like the installation does today.
Checklist