Repository navigation
docs(session): 更正 sqlite-compat 损坏库的抛点说明,区分读写两条路径 - #1046
Merged
Merged
Conversation
#852 合入后留下的注释不准确:`openDbForRead` 里「corrupt → throw here」挂在 `PRAGMA busy_timeout` 之前,但那条语句是连接级设置、不碰数据库页,损坏文件 过得去——这条路径实际会**成功返回一个句柄**,真正的抛点是调用方的 SELECT。 按字面读会得出「open 返回成功 ⇒ 文件可用」这种危险结论。 三处一并对齐实测行为(Node 22.21.1 与 Bun 1.4.0 一致): - 构造函数不校验文件; - `PRAGMA busy_timeout` 也不校验(连接级,不碰页); - 写路径 `openDbForOwnStore`:第一条能拒绝损坏库的是紧随的 `journal_mode`, 仍在 helper 内; - 读路径 `openDbForRead`:helper 返回句柄,抛在调用方首个 SELECT。 两种抛点都落在扫描循环的 try 内(只 rethrow SessionStoreSqliteUnavailableError、 其余 skip),所以「损坏=可跳过 / 缺引擎=fail-closed」的分型不变。 纯注释改动,运行时逻辑零变化。 验证:去掉注释后与 master 逐字节相同(证明未动代码);`tsc` 干净; session-store 四套件 198 passed;上述四条断言在 Node 与 Bun 双 runtime 实测为真。
Owner
Author
|
【交叉复核通过(pi 侧)】独立验证:两文件 strip 注释后与 master(c7e6da762)逐字节相同,纯注释零逻辑变化、未触碰任何测试/daemon 文件;session-store 三套件 109 passed;新注释的每条断言(构造不校验 / busy_timeout 不校验 / 写路径 journal_mode 拒绝且仍在 helper 内 / 读路径返回句柄、抛点在调用方首个 SELECT)与本轮双 runtime(Node 22.21.1 / Bun 1.4.0)实测行为一致。措辞比原注释精确,按字面读不再会推出「open 返回成功 ⇒ 文件可用」的危险结论,「损坏=可跳过 / 缺引擎=fail-closed」分型保留正确。无意见,可合。(注:本环境 gh token 与 PR author 同账号 deepcoldy,GitHub 拒绝自审 approve,故以评论留档;合码 approval 需申晗或其他账号,或 --admin。) |
|
🚀 Released in v3.18.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
为什么
#852 合入后留下三处注释与实际行为不符,其中一处会导致危险的误读。
session-store.ts的openDbForRead里:「throw here」指紧随其后的
busy_timeout,但那是连接级设置、不碰数据库页,损坏文件过得去——这条路径实际会成功返回一个句柄,真正的抛点是调用方的SELECT。按字面读会得出「openDbForRead返回成功 ⇒ 文件可用」,这是最危险的一种误读。改了什么
三处注释一并对齐实测行为(纯注释,运行时逻辑零变化):
openDbForOwnStorebusy_timeout都不校验;第一条能拒绝损坏库的是紧随的journal_mode,仍在 helper 内openDbForReadbusy_timeout不是校验点,helper 会为损坏库返回句柄;校验发生在调用方首个 page-touching 语句(SELECT)openDatabaseSyncOrThrowJSDocPRAGMA busy_timeout, so … throws inside the open helper's caller」分型结论不变:两种抛点都落在扫描循环的
try内(只 rethrowSessionStoreSqliteUnavailableError、其余 skip),所以「损坏 = 可跳过 / 缺引擎 = fail-closed」完整成立。代码无需改动。影响面
仅
src/services/session-store.ts与src/services/sqlite-compat.ts的注释。不改运行时行为,不影响任何 CLI、会话类型、后端或平台。验证
perlstrip 注释后diff为空)。tsc -p tsconfig.json --noEmit干净(exit 0)。session-store-sqlite/session-store/fs-policy/session-store-bwrap四套件 198 passed。.db):