Skip to content

Conversation

@weareoutman
Copy link
Member

@weareoutman weareoutman commented Oct 22, 2025

依赖检查

组件之间的依赖声明,是微服务组件架构下的重要信息,请确保其正确性。

请勾选以下两组选项其中之一:

  • 本次 MR 没有使用上游组件(例如框架、后台组件等)的较新版本提供的特性。

或者:

  • 本次 MR 使用了上游组件(例如框架、后台组件等)的较新版本提供的特性。
  • 在对应的文件中更新了该上游组件的依赖版本(或确认了当前声明的依赖版本已包含本次 MR 使用的新特性)。

提交信息检查

Git 提交信息将决定包的版本发布及自动生成的 CHANGELOG,请检查工作内容与提交信息是否相符,并在以下每组选项中都依次确认。

破坏性变更是针对于下游使用者而言,可以通过本次改动对下游使用者的影响来识别变更类型:

  • 下游使用者不做任何改动,仍可以正常工作时,那么它属于普通变更。
  • 反之,下游使用者不做改动就无法正常工作时,那么它属于破坏性变更。

例如,构件修改了一个属性名,小产品 Storyboard 中需要使用新属性名才能工作,那么它就是破坏性变更。
又例如,构件还没有任何下游使用者,那么它的任何变更都是普通变更。

破坏性变更:

  • ⚠️ 本次 MR 包含破坏性变更的提交,请继续确认以下所有选项:
  • 没有更好的兼容方案,必须做破坏性变更。
  • 使用了 feat 作为提交类型。
  • 标注了 BREAKING CHANGE: 你的变更说明
  • 同时更新了本仓库中所有下游使用者的调用。
  • 同时更新了本仓库中所有下游使用者对该子包的依赖为即将发布的 major 版本。
  • 同时为其它仓库的 Migrating 做好了准备,例如文档或批量改动的方法。
  • 手动验证过破坏性变更在 Migrate 后可以正常工作。
  • 破坏性变更所在的提交没有意外携带其它子包的改动。

新特性:

  • 本次 MR 包含新特性的提交,且该提交不带有破坏性变更,并使用了 feat 作为提交类型。
  • 给新特性添加了单元测试。
  • 手动验证过新特性可以正常工作。

问题修复:

  • 本次 MR 包含问题修复的提交,且该提交不带有新特性或破坏性变更,并使用了 fix 作为提交类型。
  • 给问题修复添加了单元测试。
  • 手动验证过问题修复得到解决。

杂项工作:

即所有对下游使用者无任何影响、且没有必要显示在 CHANGELOG 中的改动,例如修改注释、测试用例、开发文档等:

  • 本次 MR 包含杂项工作的提交,且该提交不带有问题修复、新特性或破坏性变更,并使用了 chore, docs, test 等作为提交类型。

Summary by CodeRabbit

发布说明

  • 功能增强

    • 增强了运行时认证系统集成。
  • 性能改进

    • 优化了缓存管理机制,改进了数据解析效率。
    • 完善了增量渲染流程中的缓存处理逻辑。

@weareoutman weareoutman changed the base branch from master to v3 October 22, 2025 10:20
@coderabbitai
Copy link

coderabbitai bot commented Oct 22, 2025

Walkthrough

此PR修改了运行时上下文初始化、缓存清理机制和数据解析逻辑。用懒加载的isStale函数替换布尔值标志,并在增量路由渲染时集成缓存清理。

Changes

内聚体 / 文件 变化摘要
运行时上下文扩展
packages/runtime/src/createRoot.ts
导入hooks模块,在unstable_createRoot创建的runtimeContext对象中添加sys属性,通过hooks.auth.getAuth()初始化
缓存清理集成
packages/runtime/src/internal/Renderer.ts
导入clearResolveCache函数,在增量子路由渲染路径中的作用域运行时上下文创建前调用clearResolveCache()
数据解析优化
packages/runtime/src/internal/data/resolveData.ts
将布尔型stale标志替换为懒加载的isStale函数;更新resolveByProvider签名从isStale?: boolean改为isStale?: () => boolean;调整条件判断从!stale改为!isStale?.()

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

涉及三个相互关联的文件,包括API签名变化(resolveByProvider)、懒加载逻辑引入和缓存管理流程整合。变化跨越多个层级但遵循一致的模式,需要理解缓存清理和数据解析的交互。

Pre-merge checks and finishing touches

❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Title Check ⚠️ Warning 标题"Steve/v3-data-attrs"看起来是分支名称而非描述性的PR标题。根据代码摘要,该PR涉及多项变化,包括在runtimeContext中添加sys属性、在增量渲染中清除缓存以及将stale布尔标志替换为延迟求值函数。标题没有清楚地传达这些主要变化的目的或内容,无法让团队成员通过扫描历史快速理解这一变更的关键点。
Description Check ⚠️ Warning PR描述直接复制了模板内容,但所有必填检查项均未完成。依赖检查部分的两组选项都未勾选,提交信息检查部分的四类变更类型(破坏性变更、新特性、问题修复、杂项工作)中没有任何一类被选中并填写对应的核验项。简单描述和Todo部分虽然是可选的,但它们也被完全注释掉,整个描述缺乏对工作内容的实质性说明。 作者需要完成所有必填项:首先在依赖检查部分勾选合适的一组选项;其次根据PR的实际变更类型(从代码摘要看涉及内部API签名改变),在提交信息检查部分识别正确的变更类型并勾选对应的所有核验项;最后建议填写简单描述部分说明具体工作内容,而不仅仅提交空白的模板。
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch steve/v3-data-attrs

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 4e54c36 and 7a0dfae.

📒 Files selected for processing (3)
  • packages/runtime/src/createRoot.ts (2 hunks)
  • packages/runtime/src/internal/Renderer.ts (2 hunks)
  • packages/runtime/src/internal/data/resolveData.ts (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build (20.x)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
packages/runtime/src/internal/data/resolveData.ts (1)

85-98: LGTM!懒加载的陈旧性检查实现得很好。

将陈旧性检查从提前计算的布尔值改为懒加载函数是一个很好的重构,它确保了在真正需要判断缓存是否应该被使用时才进行检查,而不是在 Promise 解析前就固定判断结果。这样可以正确处理在 Promise 解析过程中调用 clearResolveCache 的情况。

Also applies to: 140-140, 174-174

packages/runtime/src/internal/Renderer.ts (1)

947-948: 审查注释基于对缓存清除时机的误解,实际代码设计合理。

缓存清除逻辑经过验证后发现:

  1. 缓存作用域明确:全局缓存在路由导航边界处清除(Router.ts:278),每次新路由获得独立的 renderId。

  2. 调用时机恰当

    • Router.ts:路由导航开始时清除(line 273-278,新 renderId 生成后立即清除)
    • Renderer.ts:同一渲染上下文内的增量渲染转换时清除
  3. 并发保护充分:isStale 函数(resolveData.ts:85-88)在异步操作中途若 renderId 变化则标记结果失效,有效隔离不同路由的缓存。

  4. 不会影响"无关路由/组件":不同路由使用不同 renderId,通过 renderId !== _internalApiGetRenderId() 检查自动失效旧缓存的结果。

此处的缓存清除设计是合理的,无性能风险。

Likely an incorrect or invalid review comment.

packages/runtime/src/createRoot.ts (1)

155-157: 审查意见不正确,该代码已具备完整的类型安全保障。

对代码进行了详细的类型系统验证:

  • sys 属性类型定义为 Record<string, unknown>(来自 LegacyCompatibleRuntimeContext),显式允许任意字符串属性和任意值
  • getAuth() 返回 AuthInfo 类型,即 Omit<AuthApi_CheckLoginResponseBody, "loggedIn">,这是来自外部 SDK 的规范类型定义
  • 使用可选链 hooks?.auth?.getAuth() 安全处理未定义情况
  • AuthInfo 对象展开到 Record<string, unknown> 类型的目标完全符合类型规范

该代码无需额外的类型验证或运行时检查,类型系统已经完整覆盖了这个使用场景。

Likely an incorrect or invalid review comment.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@weareoutman weareoutman reopened this Oct 22, 2025
@weareoutman weareoutman requested a review from Copilot October 22, 2025 10:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the stale check mechanism in data resolution to use a function instead of a static boolean value, and adds auth information to the runtime context.

  • Refactored stale check from a boolean to a lazy-evaluated function for more accurate staleness detection
  • Added clearResolveCache() call in the legacy render flow
  • Integrated auth data into the runtime context's sys object

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/runtime/src/internal/data/resolveData.ts Changed stale from boolean to isStale function for lazy evaluation; fixed comment typo
packages/runtime/src/internal/Renderer.ts Added clearResolveCache() call before rendering and imported the function
packages/runtime/src/createRoot.ts Added sys object with auth data to runtime context initialization

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.20%. Comparing base (4e54c36) to head (7a0dfae).
⚠️ Report is 3 commits behind head on v3.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##               v3    #4813   +/-   ##
=======================================
  Coverage   95.20%   95.20%           
=======================================
  Files         212      212           
  Lines        9319     9320    +1     
  Branches     1793     1793           
=======================================
+ Hits         8872     8873    +1     
  Misses        328      328           
  Partials      119      119           
Files with missing lines Coverage Δ
packages/runtime/src/createRoot.ts 96.66% <ø> (ø)
packages/runtime/src/internal/Renderer.ts 93.71% <100.00%> (+0.01%) ⬆️
packages/runtime/src/internal/data/resolveData.ts 91.66% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cypress
Copy link

cypress bot commented Oct 22, 2025

next-core    Run #11773

Run Properties:  status check passed Passed #11773  •  git commit 8dd3d7a12a ℹ️: Merge 7a0dfae30c5bea63bf6fe2ff75c1f68024fbe5f9 into 4e54c36ef9c149514c4cebf1894c...
Project next-core
Branch Review steve/v3-data-attrs
Run status status check passed Passed #11773
Run duration 00m 24s
Commit git commit 8dd3d7a12a ℹ️: Merge 7a0dfae30c5bea63bf6fe2ff75c1f68024fbe5f9 into 4e54c36ef9c149514c4cebf1894c...
Committer Shenwei Wang
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 17
View all changes introduced in this branch ↗︎

@weareoutman weareoutman merged commit 0cd2472 into v3 Oct 22, 2025
10 checks passed
@weareoutman weareoutman deleted the steve/v3-data-attrs branch October 22, 2025 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant