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

Feature request: support undici (native fetch) #239

Open
idranme opened this issue Aug 24, 2023 · 0 comments
Open

Feature request: support undici (native fetch) #239

idranme opened this issue Aug 24, 2023 · 0 comments

Comments

@idranme
Copy link

idranme commented Aug 24, 2023

node:internal/deps/undici/undici:11576
    Error.captureStackTrace(err, this);
          ^

TypeError: fetch failed
    at Object.fetch (node:internal/deps/undici/undici:11576:11)
    at async file:///D:/develop/fetch-proxy/index.mjs:5:13 {
  cause: TypeError: agent.dispatch is not a function
      at node:internal/deps/undici/undici:11453:55
      at new Promise (<anonymous>)
      at dispatch (node:internal/deps/undici/undici:11453:16)
      at httpNetworkFetch (node:internal/deps/undici/undici:11354:73)
      at httpNetworkOrCacheFetch (node:internal/deps/undici/undici:11256:39)
      at httpFetch (node:internal/deps/undici/undici:11105:43)
      at schemeFetch (node:internal/deps/undici/undici:11033:24)
      at node:internal/deps/undici/undici:10909:26
      at mainFetch (node:internal/deps/undici/undici:10926:11)
      at fetching (node:internal/deps/undici/undici:10883:7)
}

It will report error:

import { ProxyAgent } from 'proxy-agent'

const client = new ProxyAgent('http://127.0.0.1:7890/')

const res = await fetch('https://google.com', {
  dispatcher: client
})
const text = await res.text()
console.log(text)

It won't report errors:

import { ProxyAgent } from 'undici'

const client = new ProxyAgent('http://127.0.0.1:7890/')

const res = await fetch('https://google.com', {
  dispatcher: client
})
const text = await res.text()
console.log(text)

API Reference: https://github.com/nodejs/node/blob/feb5b0fef8def15c801e4b950d662d76f41ed52c/deps/undici/src/docs/api/Dispatcher.md#dispatcherdispatchoptions-handler

Reference implementation: https://github.com/nodejs/node/blob/da197d189021b34db1164ec68f123c885877b2ee/deps/undici/src/lib/proxy-agent.js#L123

@idranme idranme changed the title support native fetch Feature: Support native fetch Aug 24, 2023
@idranme idranme changed the title Feature: Support native fetch Feature: support native fetch Aug 24, 2023
@idranme idranme changed the title Feature: support native fetch Feature request: support native fetch Aug 24, 2023
@idranme idranme changed the title Feature request: support native fetch Feature request: support undici(native fetch) Aug 24, 2023
@idranme idranme changed the title Feature request: support undici(native fetch) Feature request: support undici (native fetch) Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant