-
Notifications
You must be signed in to change notification settings - Fork 124
fix: fix socket info if fetch failed #556
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
WalkthroughThe changes in this pull request enhance the Changes
Possibly related PRs
Suggested reviewers
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 (
|
commit: |
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: 1
🧹 Outside diff range and nitpick comments (2)
test/fetch.test.ts (1)
61-61: Fix grammatical error in test nameThe test name "fetch error should has socket info" contains a grammatical error.
- it('fetch error should has socket info', async () => { + it('fetch error should have socket info', async () => {src/fetch.ts (1)
221-222: Consider enhancing error type handlingThe error handling looks good with the addition of socket info update and timing. Consider adding specific handling for different error types (network errors, timeout errors, etc.) for better diagnostics.
} catch (e: any) { + const errorType = e instanceof DOMException ? e.name : 'NetworkError'; updateSocketInfo(socketInfo, internalOpaque /* , rawError */); urllibResponse.rt = performanceTime(requestStartTime); + urllibResponse.errorType = errorType;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
src/fetch.ts(1 hunks)src/utils.ts(1 hunks)test/fetch.test.ts(1 hunks)
🔇 Additional comments (1)
src/utils.ts (1)
162-162: LGTM! Socket info retrieval enhancement
The addition of error socket fallback using nullish coalescing is a good improvement for more reliable socket info retrieval.
| } catch (error) { | ||
| console.log(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.
🛠️ Refactor suggestion
Improve error handling in test
The current error handling simply logs the error without any assertions. Consider adding explicit error type checking and assertions.
} catch (error) {
- console.log(error);
+ expect(error).toBeInstanceOf(DOMException);
+ expect(error.name).toBe('TimeoutError');
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| } catch (error) { | |
| console.log(error); | |
| } | |
| } catch (error) { | |
| expect(error).toBeInstanceOf(DOMException); | |
| expect(error.name).toBe('TimeoutError'); | |
| } |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #556 +/- ##
==========================================
+ Coverage 93.69% 94.60% +0.90%
==========================================
Files 11 11
Lines 1221 1223 +2
Branches 295 297 +2
==========================================
+ Hits 1144 1157 +13
+ Misses 73 62 -11
Partials 4 4 ☔ View full report in Codecov by Sentry. |
[skip ci] ## [4.6.2](v4.6.1...v4.6.2) (2024-12-04) ### Bug Fixes * fix socket info if fetch failed ([#556](#556)) ([e9f4258](e9f4258))
Summary by CodeRabbit
New Features
Bug Fixes
Tests