-
-
Notifications
You must be signed in to change notification settings - Fork 998
feat(x-sdk): XRequest support retry #1629
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
* chore: changelog of 2.1.2 * chore: changelog of 2.1.2
* feat: test * feat: x-sdk default messages * feat: x-sdk default messages * feat: x-sdk default messages * test: x-sdk * feat: x-sdk default messages * feat: x-sdk default messages * feat: x-sdk default messages * feat: x-sdk default messages * test: x-sdk * test: x-sdk * feat:s-sdk * feat:s-sdk * feat:s-sdk * test: x-sdk * test: x-sdk * test: x-sdk * test: x-sdk * feat:s-sdk * feat:s-sdk * feat:s-sdk * feat:s-sdk * feat:s-sdk * feat:s-sdk * feat: push * fix: geshi * fix: geshi
* chore: changelog of 2.1.3 * chore: changelog of 2.1.3 * chore: changelog of 2.1.3
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* fix: attachments * fix: attachments * feat: browseeruse * test: snap * test: snap * test: file card * test: file card * test: file card * feat: test * feat: test * fix: attachments * fix: attachments * fix: attachments
* fix: inster container * feat: cursor * feat: cursor * feat: cursor * feat: slot test * test: custom slot * feat: test of sender * feat: test of sender * test: sender * test: sender * feat: hook cursor * feat: hook cursor * feat: hook cursor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @hylin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a robust retry mechanism for the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Deploying ant-design-x with
|
| Latest commit: |
f87ca3c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5dc5e50f.ant-design-x.pages.dev |
| Branch Preview URL: | https://feat-request-retry.ant-design-x.pages.dev |
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.
Code Review
This pull request introduces a retry mechanism for XRequest, which is a great addition for improving request reliability. The implementation correctly handles retry intervals, retry limits, and resuming SSE streams using Last-Event-ID.
Beyond the core feature, this PR includes a substantial amount of valuable refactoring and cleanup across the codebase:
- Dependency updates and replacement of
classnameswithclsx. - Enabling the
noUndeclaredDependencieslint rule inbiome.jsonto improve dependency management. - Significant refactoring of tests for the
Sendercomponent, making them more structured and maintainable. - Improvements in the
Sendercomponent's internal logic, especially around cursor handling and DOM manipulation, which enhance robustness. - Refactoring in
FileCardandAttachmentscomponents to use enums and resolve prop name collisions, improving code clarity.
I have one suggestion regarding the implementation of the retry logic in XRequest to improve maintainability by avoiding state mutation in an async context. Overall, this is a high-quality contribution with many positive changes.
| clearTimeout(this.retryTimer); | ||
| this.retryTimer = setTimeout(() => { | ||
| const originalHeaders = this.options.headers; | ||
| if (this.lastEventId) { | ||
| // Temporarily add Last-Event-ID header for retry | ||
| this.options.headers = { | ||
| ...(originalHeaders || {}), | ||
| [LastEventId]: this.lastEventId, | ||
| }; | ||
| } | ||
| this.init(this.lastManualParams); | ||
| // Restore original headers after initiating the retry request | ||
| this.options.headers = originalHeaders; | ||
| }, retryInterval); | ||
| this.retryTimes = this.retryTimes + 1; | ||
| } | ||
| }); |
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.
The current implementation for retrying with Last-Event-ID temporarily mutates this.options.headers. While this works because init() is synchronous in its setup, mutating instance properties within an asynchronous callback can be fragile and is generally considered a code smell. It can lead to race conditions if the class's logic changes in the future.
A safer and cleaner approach is to avoid mutation by passing any request-specific headers down through the call chain.
You could refactor init to accept an additional extraHeaders parameter and merge it when creating the request.
For example:
-
Modify the
initmethod signature:private init(extraParams?: Partial<Input>, extraHeaders?: Record<string, string>) {
-
Update header creation inside
init:const { headers = {}, ... } = this.options; // ... const requestInit: XRequestOptions<Input, Output> = { // ... headers: { ...globalOptions.headers, ...headers, ...extraHeaders }, // ... };
-
Update the
setTimeoutcallback in thecatchblock to pass the headers without mutation:this.retryTimer = setTimeout(() => { const extraHeaders = this.lastEventId ? { [LastEventId]: this.lastEventId } : undefined; this.init(this.lastManualParams, extraHeaders); }, retryInterval); this.retryTimes += 1;
This avoids side effects and makes the data flow more explicit.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature #1629 +/- ##
===========================================
- Coverage 97.16% 97.15% -0.01%
===========================================
Files 140 140
Lines 4296 4322 +26
Branches 1211 1209 -2
===========================================
+ Hits 4174 4199 +25
- Misses 120 121 +1
Partials 2 2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
size-limit report 📦
|
Bundle ReportChanges will decrease total bundle size by 56.45kB (-1.8%) ⬇️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: x-markdown-array-pushAssets Changed:
view changes for bundle: antdx-array-pushAssets Changed:
|

中文版模板 / Chinese template
🤔 This is a ...
🔗 Related Issues
close #1587
💡 Background and Solution
📝 Change Log