-
-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
This is the same bug as #1556 but for .reply called with a single callback instead of a callback for data. I believe I have identified the cause:
Line 226 in 472c40e
| mockDispatch.data = { ...mockDispatch.data, ...mockDispatch.data.callback(opts) } |
This callback is called with the raw options passed as opposed to the mutated options that later gets passed to a "data" callback
Reproducible By
import { MockAgent, setGlobalDispatcher } from 'undici'
const mockAgent = new MockAgent()
const mockPool = mockAgent.get('http://localhost')
setGlobalDispatcher(mockAgent)
mockPool.intercept({
path: '/foo',
method: 'GET',
}).reply((options) => {
console.log('headers in reply:', Object.prototype.toString.call(options.headers), options.headers)
return { statusCode: 200 };
})
await fetch('http://localhost/foo')Expected Behavior
As specified in the type definitions, I would expect a Headers object when using fetch()
Logs & Screenshots
headers in reply: [object Array] [
'accept',
'*/*',
'accept-language',
'*',
'sec-fetch-mode',
'cors',
'user-agent',
'undici',
'accept-encoding',
'gzip, deflate'
]
Environment
- Windows 10
- Node v18.15.0
- Undici 5.21.2
- Fetch used is global fetch in node, not imported from undici
Additional context
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working