-
-
Notifications
You must be signed in to change notification settings - Fork 969
Closed
Labels
bugSomething does not work as it shouldSomething does not work as it shouldregressionSomething does not work anymoreSomething does not work anymore✭ help wanted ✭
Description
Describe the bug
Using got.post
with both body
and cache
options causes an exception.
- Node.js version: 13.6.0
- OS & version: Fedora 30
- got version: 10.2.2
Actual behavior
GotError: Cannot read property 'on' of undefined
at onError (/usr/src/npm/failures/got-test/node_modules/got/dist/source/request-as-event-emitter.js:137:29)
at EventEmitter.handleRequest (/usr/src/npm/failures/got-test/node_modules/got/dist/source/request-as-event-emitter.js:170:17)
at destroyer (internal/streams/pipeline.js:27:10)
at internal/streams/pipeline.js:79:12
at Array.map (<anonymous>)
at pipeline (internal/streams/pipeline.js:76:28)
at internal/util.js:297:30
at new Promise (<anonymous>)
at pipeline (internal/util.js:296:12)
at EventEmitter.handleRequest (/usr/src/npm/failures/got-test/node_modules/got/dist/source/request-as-event-emitter.js:162:23)
at Object.onceWrapper (events.js:428:26)
at EventEmitter.emit (events.js:321:20) {
name: 'RequestError'
}
Expected behavior
No exception. Unsure if options.cache
should do anything in this case or be ignored. For my own use that does not matter as the server I'm really working with never provides cachable responses to POST requests. Really the goal for me is to be able to use a shared "base options" object and not have to censor the cache
option when performing posts.
Code to reproduce
#!/usr/bin/env node
'use strict';
const got = require('got');
async function main() {
await got.post('https://httpbin.org/post', {
body: '',
cache: new Map()
});
}
main().catch(error => {
console.error(error);
process.exit(1);
});
Checklist
- I have read the documentation.
- I have tried my code with the latest version of Node.js and Got.
andywampir
Metadata
Metadata
Assignees
Labels
bugSomething does not work as it shouldSomething does not work as it shouldregressionSomething does not work anymoreSomething does not work anymore✭ help wanted ✭