Skip to content
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

[BUG] Error: Cannot set headers after they are sent to the client #244

Open
1 task done
pflannery opened this issue May 30, 2024 · 0 comments
Open
1 task done

[BUG] Error: Cannot set headers after they are sent to the client #244

pflannery opened this issue May 30, 2024 · 0 comments
Labels
Bug thing that needs fixing Needs Triage needs an initial review

Comments

@pflannery
Copy link

pflannery commented May 30, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Error Message

Error: Cannot set headers after they are sent to the client
	at new NodeError (node:internal/errors:405:5)
	at ClientRequest.setHeader (node:_http_outgoing:648:11)
	at Agent.addRequest (c:\Users\xxx\.vscode\extensions\pflannery.vscode-versionlens-1.11.0\node_modules\@npmcli\agent\lib\agents.js:178:13)
	at c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\agent-base\dist\index.js:77:31

A couple of users of my vscode extension versionlens have recently experienced this issue

Versionlens uses [email protected]. I tracked down this error to be related to a sub dependency of this package @npmcli/agent v2.2.2 which got installed in a recent update via the versionlens package-lock.json file.

The error occurs here

When the users rolled back versionlens they reported the error had gone away but the version they rolled back to also uses [email protected] so its a sub dependency update that is causing the problem.

I'm not sure how to recreate the issue as I can't seem to hit the line of code with the error so it seems to be npm config specific.

I'm wondering if the solution is as simple as adding a check

if (!request.headers.has('connection')) {
    request.headers.set('connection', agent ? 'keep-alive' : 'close')
  }

Expected Behavior

No errors

Steps To Reproduce

No response

Environment

  • npm: 10.2.4
  • Node: v18.19.1
  • OS: Windows_NT x64 10.0.19045
@pflannery pflannery added Bug thing that needs fixing Needs Triage needs an initial review labels May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs an initial review
Projects
None yet
Development

No branches or pull requests

1 participant