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

"Error: Request was cancelled" when using ProxyAgent #2161

Closed
NBNGaming opened this issue Jun 16, 2023 · 7 comments · Fixed by #2162
Closed

"Error: Request was cancelled" when using ProxyAgent #2161

NBNGaming opened this issue Jun 16, 2023 · 7 comments · Fixed by #2162
Labels
bug Something isn't working

Comments

@NBNGaming
Copy link
Contributor

Bug Description

When using ProxyAgent and http proxy responds with status code !== 200, Undici throws "Error: Request was cancelled". This error message is confusing and irrelevant to problem cause.
This line throws error:

callback(new RequestAbortedError('Proxy response !== 200 when HTTP Tunneling'))

Expected Behavior

Throwing error with meaningful error "Proxy response !== 200 when HTTP Tunneling".

Logs & Screenshots

TypeError: fetch failed
    at fetch (node_modules/undici/index.js:109:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  cause: Error: Request was cancelled.
      at makeNetworkError (node_modules/undici/lib/fetch/response.js:351:9)
      at makeAppropriateNetworkError (node_modules/undici/lib/fetch/response.js:437:7)
      at httpNetworkFetch (node_modules/undici/lib/fetch/index.js:1763:14)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async httpNetworkOrCacheFetch (node_modules/undici/lib/fetch/index.js:1450:29)
      at async httpFetch (node_modules/undici/lib/fetch/index.js:1030:33)
      at async schemeFetch (node_modules/undici/lib/fetch/index.js:886:14)
      at async node_modules/undici/lib/fetch/index.js:599:16
      at async mainFetch (node_modules/undici/lib/fetch/index.js:583:16)
}

Environment

Ubuntu 22.04.2 and Windows 11
Node.js 18.16.0
Undici v5.22.1

@NBNGaming NBNGaming added the bug Something isn't working label Jun 16, 2023
@ronag
Copy link
Member

ronag commented Jun 16, 2023

PR welcome

@ronag
Copy link
Member

ronag commented Jun 16, 2023

The cause message should probably not be Request was cancelled. I'm not sure why the proper message isn't forwarded.

@NBNGaming
Copy link
Contributor Author

Because this line replaces proper error with Request was cancelled

: makeNetworkError('Request was cancelled.')

@ronag
Copy link
Member

ronag commented Jun 16, 2023

Hm. Then I don't know what we can do without violating the spec. @KhafraDev

@KhafraDev
Copy link
Member

a possible solution is to add an optional cause to makeNetworkError

@KhafraDev
Copy link
Member

or we could forward the error message (haven't looked into if we can do it), it doesn't have to be Request was cancelled.. Not sure what part of that would violate the spec since it's only the error's cause?

@NBNGaming
Copy link
Contributor Author

So, my pull request #2162 now can be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants