-
Notifications
You must be signed in to change notification settings - Fork 358
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
fix(device): error catch for device deletion #4056
base: next
Are you sure you want to change the base?
fix(device): error catch for device deletion #4056
Conversation
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint
warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options. (For a CapTP with native promises, see @endo/eventual-send and @endo/captp) WalkthroughThe changes focus on enhancing error handling in the Changes
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 2
🧹 Nitpick comments (2)
packages/@webex/internal-plugin-device/src/device.js (2)
499-502
: Add logging for successful device deletions.Adding logs for successful deletions would help track the cleanup process and verify that the excessive registrations issue is being properly addressed.
Apply this diff to add success logging:
urlsToDelete.map((url) => { return this.request({ uri: url, method: 'DELETE', - }); + }).then(() => { + this.logger.info('devices: successfully deleted device', { url }); + }).catch((error) => { + this.logger.warn('devices: failed to delete device', { url, error }); + throw error; + });
499-502
: Consider implementing a retry mechanism for failed deletions.If a device deletion fails, the current implementation gives up immediately. Adding a retry mechanism would make the cleanup process more robust.
Would you like me to provide an implementation of a retry mechanism with exponential backoff?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/@webex/internal-plugin-device/src/device.js
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: AWS Amplify Console Web Preview
🔇 Additional comments (2)
packages/@webex/internal-plugin-device/src/device.js (2)
497-498
: LGTM! Good addition of error logging.The error logging before device deletion helps track the excessive registrations error.
499-510
: Verify impact on rate limits.Multiple simultaneous DELETE requests might hit API rate limits. Consider adding a delay between requests or implementing a queue system.
return this.deleteDevices() | ||
.then(() => { | ||
return this._registerInternal(deviceRegistrationOptions); | ||
}) |
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.
Consider using Promise.all instead of Promise.race.
The current implementation using Promise.race()
only waits for the first deletion to complete, potentially leaving other deletions unfinished. This could lead to inconsistent state and not effectively solve the excessive registrations issue.
Apply this diff to wait for all deletions:
- return Promise.race(
+ return Promise.all(
urlsToDelete.map((url) => {
return this.request({
uri: url,
method: 'DELETE',
Committable suggestion skipped: line range outside the PR's diff.
This pull request is automatically being deployed by Amplify Hosting (learn more). |
c396840
to
55ca02c
Compare
…/logs-metrics-on-device-delete
COMPLETES SPARK-586651
This pull request addresses
by making the following changes
Change Type
I certified that
Make sure to have followed the contributing guidelines before submitting.
Summary by CodeRabbit
Summary by CodeRabbit