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

Add a timeout to fetch() + configurable environment variable #24

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

bnb
Copy link

@bnb bnb commented Oct 24, 2018

This PR adds a timeout to the fetch() call in /bin/ncm-ci.js. Also adds the NCM_TIMEOUT environment variable, which can be used to set a custom timeout time (2 minutes by default).

bin/ncm-ci.js Outdated Show resolved Hide resolved
Copy link
Contributor

@juliangruber juliangruber left a comment

Choose a reason for hiding this comment

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

thank you for working on this so much!!

bin/ncm-ci.js Outdated Show resolved Hide resolved
@bnb
Copy link
Author

bnb commented Oct 25, 2018

LGTM @juliangruber!

As a note, I used the all caps because of a similar environment variable in the GraphQL code 😅

@juliangruber
Copy link
Contributor

As a note, I used the all caps because of a similar environment variable in the GraphQL code 😅

oops! consistency :D

// Setting up a timeout to be used with fetch() – will use the NCM_TIMEOUT environment
// variable or default to 2 minutes (120 seconds / 120000 milliseconds)
const timeout = process.env.NCM_TIMEOUT
? Number(process.env.NCM_TIMEOUT) * 1000
Copy link

Choose a reason for hiding this comment

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

still need to check for a non-numeric string in the env var:

$ node -p 'Number("foo") * 1000'
NaN

timeout will end up being a NaN in that case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants