Replies: 0 comments 2 replies
-
Relevant: #43187 |
Beta Was this translation helpful? Give feedback.
0 replies
-
@meyfa Thanks for the link. I guess we can hack together an agent but it's very awkward. import assert from "node:assert";
// We have to execute fetch once to instantiate the global dispatcher?
fetch("https://example.com").catch(assert);
const globalDispatcher = global[Symbol.for("undici.globalDispatcher.1")];
const dispatcher = new globalDispatcher.constructor({ connectTimeout: 1 });
fetch("https://example.com", { dispatcher })
.then(assert)
.catch(error => assert(error.cause.code === "UND_ERR_CONNECT_TIMEOUT")); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm interested in providing a
dispatcher
option for my fetch calls instead of using the global dispatcher.Are these classes purposefully not being exported or have I missed something?
I see that internally the globals are exported:
node --expose-internals -e "console.log(require('node:internal/deps/undici/undici'))" { fetch: [Function: fetch], FormData: [class FormData], Headers: [class Headers], Response: [class Response] { error: [Function: error], json: [Function: json], redirect: [Function: redirect] }, Request: [class Request], WebSocket: [class WebSocket extends EventTarget] { CONNECTING: 0, OPEN: 1, CLOSING: 2, CLOSED: 3 } }
I was hoping for undici to become an exposed package, i.e. import from
'node:undici'
. Is that something in the works so that all of undici's exports can be accessible? It seems odd that I would have to install undici separately to use it internally 🤔Thanks 👍
Beta Was this translation helpful? Give feedback.
All reactions