-
Notifications
You must be signed in to change notification settings - Fork 3
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
Support HTTP_TIMEOUT environment variable #116
Conversation
@@ -9,6 +9,10 @@ export const DEFAULT_USER_AGENT_HEADERS = { | |||
'User-Agent': `HubSpot Local Dev Lib/${version}`, | |||
}; | |||
|
|||
const DEFAULT_TRANSITIONAL = { | |||
clarifyTimeoutError: true, | |||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tells axios to use ETIMEDOUT
as the code
for timeout errors
config/config_DEPRECATED.ts
Outdated
@@ -736,6 +736,9 @@ function getConfigVariablesFromEnv() { | |||
personalAccessKey: env[ENVIRONMENT_VARIABLES.HUBSPOT_PERSONAL_ACCESS_KEY], | |||
portalId: parseInt(env[ENVIRONMENT_VARIABLES.HUBSPOT_PORTAL_ID] || '', 10), | |||
refreshToken: env[ENVIRONMENT_VARIABLES.HUBSPOT_REFRESH_TOKEN], | |||
httpTimeout: env[ENVIRONMENT_VARIABLES.HTTP_TIMEOUT] | |||
? parseInt(env[ENVIRONMENT_VARIABLES.HTTP_TIMEOUT] || '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this part necessary? env[ENVIRONMENT_VARIABLES.HTTP_TIMEOUT] || ''
Since env[ENVIRONMENT_VARIABLES.HTTP_TIMEOUT]
would already have to resolve to true for this section of the ternary to run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh good catch, that was left over from before I added the ternary (and would end with httpTimeout
being NaN
if not provided)
lib/fileMapper.ts
Outdated
@@ -265,7 +265,7 @@ async function writeFileMapperNode( | |||
} | |||
|
|||
function isTimeout(err: BaseError): boolean { | |||
return !!err && (err.status === 408 || err.code === 'ESOCKETTIMEDOUT'); | |||
return !!err && (err.status === 408 || err.code === 'ETIMEDOUT'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would isSpecifiedError help here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah maybe we should update this to be able to check for code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
Description and Context
Currently, you can use the
--use-env
flag on the CLI to pull certain config values from environment variables, but until now, setting the HTTP timeout this way wasn't supported. It's possible this could cause issues for customers using CLI commands in environments where using ahubspot.config.yml
file doesn't work or doesn't make sense (see HubSpot/hubspot-cli#1015). This adds support for anHTTP_TIMEOUT
environment variable.It also makes some other more minor changes
filemapper
where timeout errors weren't being identified properlyTesting
Run a command with a request that takes a long time with a low timeout to confirm this is working.
Example:
TODO
Who to Notify
@brandenrodgers @kemmerle