-
-
Notifications
You must be signed in to change notification settings - Fork 981
Closed
Labels
Description
Hello. First time opening a bug here, so please tell me if something is missing.
Describe the bug
- Node.js version: v14.15.3
- OS & version: Arch Linux, everything updated
When retrying a request with a client with cache configured, insted of the retry we get an error
Actual behavior
RequestError: Parameters `path` and `pathname` are mutually exclusive.
at Request.<anonymous> (/home/akai/Projects/got-repro-cache-retry/node_modules/got/dist/source/as-promise/index.js:113:42)
at Object.exports.default (/home/akai/Projects/got-repro-cache-retry/node_modules/got/dist/source/core/utils/options-to-url.js:17:19)
at Function.normalizeArguments (/home/akai/Projects/got-repro-cache-retry/node_modules/got/dist/source/core/index.js:483:51)
at /home/akai/Projects/got-repro-cache-retry/node_modules/got/dist/source/as-promise/index.js:88:65
at gotAfterResponseAuth (/home/akai/Projects/got-repro-cache-retry/index.js:40:20)
at Request.<anonymous> (/home/akai/Projects/got-repro-cache-retry/node_modules/got/dist/source/as-promise/index.js:87:42)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
...
Expected behavior
The request is retried
...
Code to reproduce
const nock = require('nock')
const got = require('got')
const QuickLRU = require('quick-lru')
const cache = new QuickLRU({maxSize: 2})
let getFirstCall = true
nock('http://example.com')
.persist()
.get('/test')
.reply(() => {
if (getFirstCall) {
getFirstCall = false
return [401]
}
return [200, JSON.stringify({ wat: ['123'] })]
})
const client = got.extend({
cache,
headers: {
authorization: '321'
},
hooks: {
afterResponse: [
async function gotAfterResponseAuth(response, retryWithMergedOptions) {
if (response.statusCode === 401) {
const updatedOptions = {
headers: {
authorization: '123',
},
}
client.defaults.options = got.mergeOptions(client.defaults.options, updatedOptions)
return retryWithMergedOptions(updatedOptions)
}
return response
},
]
},
mutableDefaults: true,
shared: false,
})
async function test(){
await client.get('http://example.com/test')
}
test()Checklist
- I have read the documentation.
- I have tried my code with the latest version of Node.js and Got.
Reactions are currently unavailable