panva / openid-client

OAuth 2 / OpenID Connect Client API for JavaScript Runtimes
MIT License
1.83k stars 392 forks source link

timeout value 0 does not disable timeout #443

Closed soanaphikeste closed 2 years ago

soanaphikeste commented 2 years ago

Describe the bug When setting the global timout to 0, it remains at the default value even though 0. This is normally an accepted value that would disable the timeout completely.

To Reproduce Issuer and Client configuration: (inline or gist) - Don't forget to redact your secrets.

import { Issuer, custom } from 'openid-client';

custom.setHttpOptionsDefaults({
    timeout: 0
});

await Issuer.discover('https://some-url-to-extremely-slow-server.example.com')

Steps to reproduce the behaviour:

  1. Set the global timeout option to 0
  2. Call an extremely slow server (e.g. using Issuer.discover)
  3. Observe that a timeout error is thrown with the message RPError: outgoing request timed out after 3500ms

Expected behaviour There should not be a timout error or at least not one generated by openid-client. 3500ms is the default timeout imposed by this library, which leads me to believe that overriding the timeout did not have any effect

Environment:

Additional context The issue is most likely in the pick function, which checks for thruthy values whn selecting things.

panva commented 2 years ago

If you change the pick function to if (object[path] !== undefined) {, do you observe the expected behaviour?

soanaphikeste commented 2 years ago

Yes, that produces the expected behavior