-
-
Notifications
You must be signed in to change notification settings - Fork 688
Closed
Labels
H2Pull requests or issues related to HTTP/2Pull requests or issues related to HTTP/2bugSomething isn't workingSomething isn't working
Description
Bug Description
Dispatcher.close() is documented as:
Closes the client and gracefully waits for enqueued requests to complete before invoking the callback (or returning a promise if no callback is provided).
However, when using HTTP2 mode, the requests are terminated before the pending requests complete.
Reproducible By
import { Client } from 'undici'
const url = new URL('https://identity.foundation/.well-known/did.json')
const dispatcher = new Client(url.origin, {
allowH2: true, // <=== "true" here causes an error. "false" doesn't
})
const res = await globalThis.fetch(url, { dispatcher })
dispatcher.close().then(
() => {
console.info('closed')
},
(err) => {
console.error('failed closing', err)
},
)
await res.json()
/**
* TypeError: terminated
* at Request.onError (node_modules/.pnpm/undici@6.19.8/node_modules/undici/lib/core/request.js:299:27)
* at Object.errorRequest (node_modules/.pnpm/undici@6.19.8/node_modules/undici/lib/core/util.js:638:13)
* at abort (node_modules/.pnpm/undici@6.19.8/node_modules/undici/lib/dispatcher/client-h2.js:277:10)
* at ClientHttp2Stream.<anonymous> (node_modules/.pnpm/undici@6.19.8/node_modules/undici/lib/dispatcher/client-h2.js:452:5)
*/Expected Behavior
Same behavior as when allowH2: false: no error & client can be closed before completing.
Logs & Screenshots
Environment
Node: v18.20.4
Undici: 6.19.8
Metadata
Metadata
Assignees
Labels
H2Pull requests or issues related to HTTP/2Pull requests or issues related to HTTP/2bugSomething isn't workingSomething isn't working