Fix/recoverable checkpoint and 5.0.4#21
Merged
AthrunArthur merged 6 commits intoJul 9, 2026
Merged
Conversation
Expose onDownloadReady so UI can dismiss loading overlays after HEAD+tail validation; fix eth_hash_prefix to restore v4.x-compatible signatures. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Move download-ready signaling out of HttpSealedFileStream into a TransformStream (same pattern as createProgressTransformer) and pipe it in stream/blob download paths without modifying the HTTP stream class. Co-authored-by: Cursor <cursoragent@cursor.com>
…nsformer-5.0.4 Feat/download ready transformer 5.0.4
Resolve jest.config.browser.mjs conflict: keep callback tests and progress.spec.mjs. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
本 PR 在
develop(已合入 #20 测试改动)基础上,补齐 Node Recoverable 库侧修复,并 同步main5.0.4 浏览器更新。一、Node — Recoverable 断点续传修复
背景
#20 已将 pause/resume 测试改为 README 标准用法(不手动
saveContext),但库侧存在:saveContext()原地open('w')覆盖 + fire-and-forget,多次并发写同一文件 →context.datmeta JSON 损坏(multipause 在loadContext报Bad control character)Unsealer把remaining写成Uint8Array,saveContext只认Buffer→ 密文尾巴被JSON.stringify塞进 meta(体积膨胀、写盘更慢)readItemCount未持久化 / resume 未从 context 恢复 → 续传密文错位(Public Key could not be parsed)data的错误subarray与 Unsealerremaining语义不一致设计要求:不依赖宿主或 pause 回调调
saveContext,pause 与断电走同一套自动落盘路径。PipelineContextInFile— 落盘可靠性context.dat.tmp→fsync→rename替换正式文件;写盘中断时旧context.dat仍完整可读truncate把 meta 写花_saveDirty+_saveTail:流式解密中多次触发 save,合并为少量完整写入loadContext等待 pending saveawait _saveTail后再读盘,避免 stage 结束立刻 load 读到半成品Uint8Array→ binary 区Buffer/Uint8Array均进 binary 段,不再误进 JSONRecoverableWriteStream— 自动检查点readStart/writeStart/readItemCount并saveContext()ws.end()/_final:truncate 明文到writeStart后再 save(与 pause、异常退出路径一致)data清空,resume 从上一 item 边界重解(与断电回退一致)data的错误subarrayUnsealer— resume 自恢复context.context读取readItemCount/readStart/writeStart(宿主不必再传processedItemCount)data统一写成Buffer与 #20 测试的关系
test pipeline context with pause and resume from large filetest pipeline context with multiple random pause and resume二、同步 main — 5.0.4(PR #18)
onDownloadReadycreateDownloadReadyTransformersignMessage前缀修复ypccrypto.common.js修正 Ethereum 前缀,恢复 v4.x 兼容签名5.0.3→5.0.4test/progress.spec.mjs;jest.config.browser.mjs注册变更文件(相对 develop)
src/node/PipelineConext.js— 原子落盘、save 排队、Uint8Array binarysrc/node/Recoverable.js— 自动检查点、readItemCount 持久化src/node/Unsealer.js— resume 从 context 恢复src/browser/*、src/common/progress.js、src/common/ypccrypto.common.js— 5.0.4package.json、jest.config.browser.mjs、相关测试Test plan
npm run test:node -- test/Recoverable.spec.js -t "^test pipeline context with pause and resume from large file$"npm run test:node -- test/Recoverable.spec.js -t "^test pipeline context with multiple random pause and resume$"npm run test:node -- test/Recoverable.spec.js --forceExitnpm run test:node -- test/PipelineContext.spec.jsnpm run test:browser(含progress/downloadCallbacks/downloadUnsealedCallbacks)npm run test:node -- test/BrowserCrypto.spec.mjs(signMessage 回归)