-
Notifications
You must be signed in to change notification settings - Fork 35
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
fix: don't use the request signal in the agent #324
Conversation
So you are passing Your explanation of the root cause "reusing a signal" makes sense though, so fixing that is definitely the right approach. We just need to be sure we fix it correctly. |
If you pass in a From options to normalizedOptions directly into the new Agent. Node.js's Agent accepts the same parameters as http.request, which includes signal. So there is where it's getting attached and reused. What we need to somehow do here is differentiate when a user does want an agent attached to a request, versus when they don't. For reasons shown in this very bug it's not always wanted to attach and reuse a signal across multiple requests. But there may be reasons to still attach a signal for a given request. I suppose it does make sense that if I pass I'm gonna have to think a little more of use cases here but I think the fix may want to be in We do still, however, want to attach a |
After giving it more thought this is in fact the best solution. There's no need to try to 'guard' the Currently testing this is pretty unrealistic, as there are no traces of this in the returned response. minipass-fetch returns In order to give ourselves a better chance of not accidentally regressing here, we should add a comment explaining why |
🤖 I have created a release *beep* *boop* --- ## [14.0.2](v14.0.1...v14.0.2) (2024-10-16) ### Bug Fixes * [`fa5f233`](fa5f233) [#324](#324) don't use the request signal in the agent (#324) (@thewilkybarkid, @wraithgar) ### Chores * [`b3742c5`](b3742c5) [#323](#323) bump @npmcli/template-oss from 4.23.3 to 4.23.4 (#323) (@dependabot[bot], @npm-cli-bot) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Following an upgrade from
13.0.1
to14.0.1
(which included upgrading@npmcli/agent
from2.0.0
to3.0.0
), we've seen strange behaviour: a request works the first time, then immediately times out after that.We're setting a
signal
on each request, which due to changes in@npmcli/agent
is then also used by the agent for connections. The problem is that the original signal is used for all requests due to agent caching. Once it's been used (i.e. after the first time a request is made), no connections are possible (as they're immediately rejected). This change resolves our issue by removing the signal from the agent.I looked into adding a test, but I don't think it's possible without making real network requests.