-
Notifications
You must be signed in to change notification settings - Fork 9
feat(devtools-connect): fail fast on specific error and codes from compass-web COMPASS-9793 #592
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: main
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 |
|---|---|---|
| @@ -1,21 +1,48 @@ | ||
| // It probably makes sense to put this into its own package/repository once | ||
| // other tools start using it. | ||
|
|
||
| const NODE_SOCKET_NON_RETRY_CODES = [ | ||
| 'ECONNREFUSED', | ||
| 'ENOTFOUND', | ||
| 'ENETUNREACH', | ||
| 'EINVAL', | ||
| ]; | ||
| const COMPASS_SOCKET_SERVICE_NON_RETRY_CODES = [ | ||
| 3000, // UNAUTHORIZED | ||
| 3003, // FORBIDDEN | ||
| 4004, // NOT_FOUND | ||
| 1008, // VIOLATED_POLICY | ||
| 4101, // DO_NOT_TRY_AGAIN | ||
| ]; | ||
|
|
||
| const isCompassSocketServiceError = handleNestedErrors( | ||
| (error: Error & { code?: string | number }): boolean => { | ||
| if (error.name === 'CompassSocketServiceError') { | ||
| return ( | ||
| typeof error.code === 'number' && | ||
| COMPASS_SOCKET_SERVICE_NON_RETRY_CODES.includes(error.code) | ||
| ); | ||
| } | ||
| return false; | ||
| }, | ||
| ); | ||
|
|
||
| function isFastFailureConnectionSingleError( | ||
| error: Error & { code?: string }, | ||
| error: Error & { code?: string | number }, | ||
| ): boolean { | ||
| switch (error.name) { | ||
| case 'MongoNetworkError': | ||
| return /\b(ECONNREFUSED|ENOTFOUND|ENETUNREACH|EINVAL)\b/.test( | ||
| error.message, | ||
| ); | ||
| return new RegExp( | ||
| String.raw`\b(${NODE_SOCKET_NON_RETRY_CODES.join('|')})\b`, | ||
|
Collaborator
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. def overkill for me to hoist the node error codes but figured the pattern matched my new front end code stuff... this stuff is very unchanging so we can go back to not changing it. 😅 |
||
| ).test(error.message); | ||
| case 'MongoError': | ||
| return /The apiVersion parameter is required/.test(error.message); | ||
| default: | ||
| return ( | ||
| ['ECONNREFUSED', 'ENOTFOUND', 'ENETUNREACH', 'EINVAL'].includes( | ||
| error.code ?? '', | ||
| ) || isPotentialTLSCertificateError(error) | ||
| (typeof error.code === 'string' && | ||
| NODE_SOCKET_NON_RETRY_CODES.includes(error.code)) || | ||
| isPotentialTLSCertificateError(error) || | ||
| isCompassSocketServiceError(error) | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| "extends": "@mongodb-js/tsconfig-devtools/tsconfig.common.json", | ||
| "compilerOptions": { | ||
| "target": "es2020", | ||
| "lib": ["es2020", "DOM"], | ||
| "lib": ["es2021", "DOM"], | ||
|
Collaborator
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. this is just cus |
||
| "module": "commonjs", | ||
| "moduleResolution": "node" | ||
| } | ||
|
|
||
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.
Are we renaming CCS? 🙂
Uh oh!
There was an error while loading. Please reload this page.
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.
We can use the acronym
CSS🙂 /sThere 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.
( My not-so subtle move towards that direction........... 👀 ) happy to pick another name