Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default maxRetryAfter is not calculated correctly #1663

Closed
jolivaSan opened this issue Mar 12, 2021 · 2 comments · Fixed by #1667
Closed

default maxRetryAfter is not calculated correctly #1663

jolivaSan opened this issue Mar 12, 2021 · 2 comments · Fixed by #1667
Labels
bug Something does not work as it should ✭ help wanted ✭

Comments

@jolivaSan
Copy link

Describe the bug

  • Node.js version: v12.20.0
  • OS & version: macOS Mojave | 10.14.6

In got documentation sais

If maxRetryAfter is set to undefined, it will use options.timeout.

But is not working well in case of use extends

Actual behavior

Event if we use a timeout config like timeout: { request: 5000 }if don't provide a maxRetryAfter value when config is "normalized" the maxRetryAfter is being calculated as Infinity

Expected behavior

As per documentation maxRetryAfter should get 5000 as value.

Code to reproduce

const { describe, it } = require('mocha')
const { strictEqual } = require('assert').strict
const Got = require('got')

describe.only('default maxRetryAfter', function () {
  it('should get timeout value', async function () {
    const newGot = Got.extend({ timeout: { request: 5000 } })
    strictEqual(newGot.defaults.options.retry.maxRetryAfter, 5000)
  })
})

/**
      AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

Infinity !== 5000

/*

I think the problem is because the code to calculate default value for maxRetryAfter is in the method normalizeArguments() and is calculating the default value before the options are merged, for this reason get timeout as undefined and the maxRetryAfter is getting infinity value

@jolivaSan jolivaSan changed the title maxRetryAfter don't default maxRetryAfter is not calculated correctly Mar 12, 2021
@szmarczak szmarczak added bug Something does not work as it should ✭ help wanted ✭ labels Mar 12, 2021
@szmarczak
Copy link
Collaborator

Weird. {timeout:5000, retry: {maxRetryAfter: undefined}} works as expected

@szmarczak
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something does not work as it should ✭ help wanted ✭
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants