Repository navigation
fix: Improve guidance for Runtime API connection resets #432
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -96,7 +96,19 @@ class RuntimeBaseCommand extends Command { | |
|
|
||
| if (err) { | ||
| let pretty = err.message || '' | ||
| if (err.name === 'OpenWhiskError') { | ||
| const connectionErrors = [err, err.error, err.cause] | ||
| const isConnectionReset = connectionErrors.some(error => { | ||
| if (!error) return false | ||
| return error.code === 'ECONNRESET' || | ||
| /ECONNRESET/i.test(error.message || '') || | ||
| /socket hang up/i.test(error.message || '') || | ||
| /(ECONNRESET|socket hang up)/i.test(typeof error.error === 'string' ? error.error : '') | ||
| }) | ||
|
|
||
| if (isConnectionReset) { | ||
| pretty = 'the connection to the Runtime API was interrupted (socket hang up / ECONNRESET). ' + | ||
| 'Please try again in a few moments. Before you do, run `aio app use` to get the latest Adobe Developer Console configuration file.' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Before you do, run
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. Using the AIO app is a troubleshooting suggestion, not a required step for every connection reset. It may help if the project’s Adobe Developer Console configuration is stale or doesn’t match the intended workspace/runtime. |
||
| } else if (err.name === 'OpenWhiskError') { | ||
| if (err.error && err.error.error) { | ||
| pretty = err.error.error.toLowerCase() | ||
| if (err.statusCode) pretty = `${pretty} (${getStatusCode(err.statusCode)})` | ||
|
|
||
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.
Can we make the logic more cleaner by something like this -
const CONNECTION_RESET_PATTERN = /ECONNRESET|socket hang up/i const matchesConnectionReset = (value) => typeof value === 'string' && CONNECTION_RESET_PATTERN.test(value)Then use above in error check as
e.code === ECONNRESET || matchesConnectionReset(e.message) || matchesConnectionReset(e.error) || matchesConnectionReset(e)WDYT?