-
Notifications
You must be signed in to change notification settings - Fork 3.6k
in connected account, refresh-token can fail with network error #12815
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
Conversation
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.
PR Summary
Enhanced error handling in connected account token refresh operations and messaging import services to properly handle network errors and provider support issues.
- Added
TEMPORARY_NETWORK_ERROR
toConnectedAccountRefreshAccessTokenExceptionCode
to properly categorize network failures during token refresh operations - Replaced
instanceof MessageImportDriverException
with'code' in exception
check to handle plain object errors - Added new
PROVIDER_NOT_SUPPORTED
error code toMessageImportDriverExceptionCode
for better provider compatibility handling - Improved network error detection in
ConnectedAccountRefreshTokensService
by handling specific error codes (ENETUNREACH, ETIMEDOUT, etc.) - Enhanced error handling consistency by converting plain object errors to proper exception class instances
6 files reviewed, 3 comments
Edit PR Review Bot Settings | Greptile
@@ -13,4 +13,5 @@ export enum ConnectedAccountRefreshAccessTokenExceptionCode { | |||
REFRESH_TOKEN_NOT_FOUND = 'REFRESH_TOKEN_NOT_FOUND', | |||
REFRESH_ACCESS_TOKEN_FAILED = 'REFRESH_ACCESS_TOKEN_FAILED', | |||
PROVIDER_NOT_SUPPORTED = 'PROVIDER_NOT_SUPPORTED', | |||
TEMPORARY_NETWORK_ERROR = 'TEMPORARY_NETWORK_ERROR', |
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.
style: Add a trailing comma after TEMPORARY_NETWORK_ERROR to maintain consistency with enum style and make future additions cleaner
const networkErrorCodes = [ | ||
'ENETUNREACH', | ||
'ETIMEDOUT', | ||
'ECONNABORTED', | ||
'ERR_NETWORK', | ||
]; |
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.
style: Consider moving network error codes to a separate constant or enum for reusability across the codebase
this.logger.log(error?.message); | ||
this.logger.log(firstErrorCode); | ||
this.logger.log(error?.errors); |
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.
style: Use structured logging with error object instead of multiple log calls. Consider: this.logger.log({ message: error?.message, code: firstErrorCode, errors: error?.errors })
📊 API Changes ReportREST API ChangesSummary🔄 Changed Operations (63)
|
@@ -45,7 +45,7 @@ export class MessageImportExceptionHandlerService { | |||
>, | |||
workspaceId: string, | |||
): Promise<void> { | |||
if (exception instanceof MessageImportDriverException) { | |||
if ('code' in exception) { |
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.
most important change to fix the issue
🚀 Preview Environment Ready! Your preview environment is available at: http://bore.pub:28372 This environment will automatically shut down when the PR is closed or after 5 hours. |
…tyhq#12815) This PR fixes this issue from the connected account refresh token service that is This PR fixes error handling in `handleDriverException` by ensuring that errors resembling `MessageImportDriverException` are correctly detected, even if they are plain objects and not true class instances. This prevents missed exception handling due to failed `instanceof` checks. Was introduced by [this PR](twentyhq#12233) that did not know all provider cases that can occur. Fixes twentyhq#12589
This PR fixes this issue from the connected account refresh token service that is
This PR fixes error handling in
handleDriverException
by ensuring that errors resemblingMessageImportDriverException
are correctly detected, even if they are plain objects and not true class instances. This prevents missed exception handling due to failedinstanceof
checks.Was introduced by this PR that did not know all provider cases that can occur.
Fixes #12589