-
Notifications
You must be signed in to change notification settings - Fork 11
fix(): handle incremental render with error #4527
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
Walkthrough该拉取请求引入了一系列更改,主要集中在路由、数据存储和测试套件的增强。 Changes
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 (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## v3 #4527 +/- ##
=======================================
Coverage 95.20% 95.21%
=======================================
Files 205 205
Lines 8860 8876 +16
Branches 1681 1685 +4
=======================================
+ Hits 8435 8451 +16
Misses 320 320
Partials 105 105
|
next-core
|
||||||||||||||||||||||||||||
| Project |
next-core
|
| Branch Review |
steve/v3-sub-routes-error
|
| Run status |
|
| Run duration | 00m 23s |
| Commit |
|
| Committer | Shenwei Wang |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
16
|
| View all changes introduced in this branch ↗︎ | |
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: 3
🧹 Outside diff range and nitpick comments (2)
packages/runtime/src/internal/data/resolveDataStore.ts (1)
115-116: 确保主 Promise 链的错误处理一致性对
pendingResult添加相同的错误处理模式,与单个上下文的处理保持一致,这种统一的错误处理方式有助于提高代码的可维护性。不过建议考虑添加日志记录:
- pendingResult.catch(() => {}); + pendingResult.catch((error) => { + console.debug('Renderer will handle the error:', error); + });packages/runtime/src/internal/Runtime.spec.ts (1)
648-650: 优化myTimeoutProvider函数的逻辑以提高可读性在
setTimeout回调中,使用了(fail ? reject : resolve)(result),这可能不够直观。建议重写此逻辑以提高代码的可读性。您可以考虑以下修改:
setTimeout(() => (fail ? reject : resolve)(result), timeout); + setTimeout(() => { + if (fail) { + reject(result); + } else { + resolve(result); + } + }, timeout);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
- packages/runtime/src/internal/Router.ts (3 hunks)
- packages/runtime/src/internal/Runtime.spec.ts (4 hunks)
- packages/runtime/src/internal/data/DataStore.ts (4 hunks)
- packages/runtime/src/internal/data/resolveDataStore.ts (2 hunks)
🧰 Additional context used
🔇 Additional comments (9)
packages/runtime/src/internal/data/resolveDataStore.ts (1)
39-46: 改进了 Promise 错误处理机制通过添加
.catch(() => {})确保 Promise 的拒绝状态被渲染器捕获,这是一个很好的防御性编程实践。这样可以避免未处理的 Promise 拒绝导致应用崩溃。packages/runtime/src/internal/data/DataStore.ts (4)
59-60: 代码结构优化得当!类型别名
PendingStackItem的引入提高了代码的可维护性,并且遵循了 TypeScript 的最佳实践。
65-65: 类型定义更新合理!
pendingStack属性使用新的PendingStackItem类型提升了类型安全性。
72-72: 数据结构选择恰当!使用
WeakMap存储路由与待处理项的映射关系,可以确保未使用的路由被正确地垃圾回收,这是一个很好的设计选择。
564-568: 文档注释清晰明确方法的文档注释很好地解释了其用途和目的。
packages/runtime/src/internal/Router.ts (2)
88-88: 新增私有属性用于追踪引导状态新增的
#bootstrapFailed属性用于跟踪引导过程是否失败,这是一个良好的状态管理实践。
235-240: 验证增量渲染的条件判断逻辑在增量渲染的条件判断中加入了
!this.#bootstrapFailed检查,这样可以防止在引导失败时执行增量渲染。建议考虑以下几点:
- 当前实现在引导失败时会完全阻止增量渲染,这可能会影响用户体验
- 可以考虑添加日志记录,以便于调试引导失败的情况
建议添加日志记录:
if ( !ignoreRendering && !location.state?.noIncremental && !this.#bootstrapFailed ) { + console.debug('[Router] Incremental render prevented due to bootstrap failure:', { location }); ignoreRendering = await this.#rendererContext?.didPerformIncrementalRender( location, prevLocation ); }packages/runtime/src/internal/Runtime.spec.ts (2)
463-518: 请确认在增量子路由中type属性的设置是否正确在第464行,路由的
type被设置为"bricks",但在incrementalSubRoutes为true的情况下,通常type应设置为"routes"。请确认此配置是有意的,并且能够按预期工作。
1460-1571: 新增的测试用例有效验证了增量子路由的错误处理添加的测试用例成功地模拟了增量子路由在成功和失败场景下的行为,并验证了应用在这两种情况下的渲染行为。
依赖检查
组件之间的依赖声明,是微服务组件架构下的重要信息,请确保其正确性。
请勾选以下两组选项其中之一:
或者:
提交信息检查
Git 提交信息将决定包的版本发布及自动生成的 CHANGELOG,请检查工作内容与提交信息是否相符,并在以下每组选项中都依次确认。
破坏性变更:
feat作为提交类型。BREAKING CHANGE: 你的变更说明。新特性:
feat作为提交类型。问题修复:
fix作为提交类型。杂项工作:
即所有对下游使用者无任何影响、且没有必要显示在 CHANGELOG 中的改动,例如修改注释、测试用例、开发文档等:
chore,docs,test等作为提交类型。Summary by CodeRabbit