Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

fix: increase default timeout and respect value passed to ky.extend #1130

Merged
merged 4 commits into from
Oct 21, 2019

Conversation

achingbrain
Copy link
Collaborator

@achingbrain achingbrain commented Oct 18, 2019

Some of our operations take a really long time, if we don't set a timeout for ky we get the default of 10 seconds. This PR sets the timeout to false if one is not explicitly passed which disables it.

Nb. I had to add the default to false to every invocation. Looking at the code it should be enough to do it in src/lib/configure.js but it doesn't seem to be. Might be a bug in ky, I'll dig a little deeper.

Some of our operations take a really long time, if we don't set a
timeout for `ky` we get the default of 10 seconds. This PR sets
the timeout to `false` if one is not explicitly passed which
disables it.

Nb. I had to add the default to `false` to every invocation. Looking
at the code it should be enough to do it in `src/lib/configure.js`
but it doesn't seem to be.
@achingbrain
Copy link
Collaborator Author

achingbrain commented Oct 19, 2019

Predictably it's because we pass undefined for options.timeout which ky then defaults to it's own value of 10000 and not what we pass into ky.extend in src/lib/configure.js.

@achingbrain
Copy link
Collaborator Author

I've changed the timeout to wait for something stupid but not to wait forever, and also added a ignoreUndefined option to merge-options so we can filter the options we pass to ky but also not pass undefined for values.

Depends on schnittstabil/merge-options#14

@achingbrain achingbrain changed the title fix: disable timeout if not set fix: increase default timeout and respect value passed to ky.extend Oct 19, 2019
Comment on lines +73 to +77
function wrap (fn, defaults) {
return (input, options) => {
return fn(input, mergeOptions(defaults, options))
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:

const wrap = (fn, defaults) => (input, options) => fn(input, mergeOptions(defaults, options));

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this sort of deeply chained single-line-arrow-function style optimises readability for computers and not humans. It'll get minified to something similar to this anyway so there's little to gain here.

@daviddias daviddias removed their request for review October 21, 2019 12:38
@achingbrain achingbrain merged commit 25b6043 into master Oct 21, 2019
@achingbrain achingbrain deleted the disable-timeout-if-not-set branch October 21, 2019 14:30
achingbrain added a commit that referenced this pull request Oct 21, 2019
…#1130)

* fix: disable timeout if not set

Some of our operations take a really long time, if we don't set a
timeout for `ky` we get the default of 10 seconds. This PR sets
the timeout to `false` if one is not explicitly passed which
disables it.

Nb. I had to add the default to `false` to every invocation. Looking
at the code it should be enough to do it in `src/lib/configure.js`
but it doesn't seem to be.

* fix: use `ignoreUndefined` merge-options option

* chore: update bundle size

* chore: remove git url
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants