[bug] GitHub 同步:单个文件上传超时导致整批中断,且平台切换仍标记为完成
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 22/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Active
- Tech stack
- github, typescript
Research direction
Start with the serial per-file upload loop that logs fileUpload entries to sync_timing_logs.json, and check why one failed file stops the batch while primaryBackupMethod is still set to github. Also look at listRemoteLibraryFilesRaw, which returns an empty list for platform 'local'. Done means a single failed upload is recorded and the loop continues, and the switch reports a mismatch when remote and local file counts differ. The issue also bundles separate feature requests, so confirm scope with maintainers first.
Written by the indexing model from the issue text.
Description
详细描述这个 Bug
详细描述这个 Bug
从「网盘同步」切换到「Github」时,上传在单个文件超时后整批中断,但平台切换仍被标记为完成。
复现步骤
新建一个空的私有仓库(没有任何 commit)
设置 → 同步配置 → Github,填 Token + 用户名 + 仓库名
点「设为使用平台」,选「保留本地」
等切换走完
实际行为
空仓库的内容查询返回 404,界面只提示“不能同步”,看不出真实原因是“仓库为空”
手动建一个文件后再试,切换会走到「同步」阶段
同步是串行的、每文件一次 commit。第 7 个文件(76 KB)上传耗时 26377ms 后 success:false,此后没有任何后续 fileUpload 记录——剩下 21 个文件没有重试、没有跳过、直接没做
但切换最终仍把 primaryBackupMethod 设成了 github,界面显示切换完成
结果:本地 28 篇笔记,远端只有 6 篇,而用户以为已经备份好了。
预期行为
单个文件失败不应中断整批:记录失败项 → 继续下一个 → 结束后汇总“成功 N / 失败 M,点此重试”
切换完成前应校验远端文件数是否与本地一致,不一致时明确警告“还有 22 篇未上传”
空仓库应给出可操作提示:“仓库为空,请先在 GitHub 上创建任意一个文件”,而不是笼统的同步失败
另一个相关问题:向导的一致性校验必然失败
第二次进入切换向导时报:
代码块
失败阶段:复查预览/本地
文件路径:conversations/03f272a3-…
校验项目:内容哈希
预期:SHA 6f6e01cb… 大小 10601B
实际:SHA 0d934ca5… 大小 10760B
原因是「预览 → 用户确认 → 执行」之间,对话数据被 NoteGen 自己改写了(autoDataSyncDirtyDomains 有对应记录),快照哈希失效。
校验机制本身是对的(防误覆盖)。但“预览”与“执行”之间的窗口较长,只要期间有活跃数据写入就必然失败。建议执行阶段改用最新状态,或在「处理差异」里默认不勾选易变模块(记录/对话)。
补充:效率与限流
28 个文件 = 28 次独立 commit,串行执行。除了慢,也更容易触发 GitHub 的二次限流。建议改用 Git Data API 批量提交(建 blobs → 建一棵 tree → 一个 commit → 移动分支指针),一次提交完成。我这边用这个方式把 28 篇一次性推成功。
背景:我们本来想做的方案(供参考,附我们的结论)
我们真正想要的是「文件系统即真实」:用 Syncthing 在多端同步 .md,NoteGen 只做编辑器。为此试了两条路,都没走通,最后才退到 GitHub。
路线一:用「本地存储」平台 + 外部 Syncthing
platform 选 local 时,listRemoteLibraryFilesRaw 里 platform === 'local' 直接 return [],远端清单恒为空,灰点归零——这一步是成立的。代价是 data(对话/记忆/设置)也不再同步。
路线二:把 Syncthing 的配置页集成进 NoteGen 的 UI
三层都被封死:
插件 embedded view 的 CSP 是 connect-src 'none' + frame-src 'none',且 sandbox="allow-scripts" 没有 allow-same-origin —— 既不能 iframe 嵌 Syncthing WebUI,也不能 fetch 它的 REST
network.fetch 的授权弹窗里明确写着「不接受…HTTP」,而 Syncthing REST 是 http://127.0.0.1:PORT
纯资源包(resources.embeddedViews)不允许声明 contributes / activationEvents(CLI 报 manifest.resource-execution),所以 iframe 拿不到任何 UI 入口;而 entry 插件跑在 Worker 里,没有 terminal 能力
结论:能拿到数据的一侧(iframe + terminal)挂不上 UI,能挂 UI 的一侧(entry 声明式视图)拿不到数据。
由此产生的建议(可作为 feature request)
希望能提供「外部同步 / 本地优先」模式:
文件树只反映磁盘状态,不与远端清单合并;或
在同步设置里加一个开关「跳过远端清单合并」
这样用 Syncthing / iCloud / OneDrive 客户端同步目录的用户,既不会被 remote-only 灰点困扰,又能保留 data 同步。对「不想自建服务、也不想维护 fork」的用户,这可能是最实用的一个开关。
临时规避
用 Git Data API 手动把剩余 22 个文件一次性提交,两边集合已对齐(28/28,无远端独有文件)。
NoteGen 版本
0.39.0(Windows 桌面端)
操作系统
Windows
报错日志
sync_timing_logs.json 关键记录:
json
{"operation":"fileUpload","path":"编程规范/bug记录.md","success":true}
{"operation":"fileUpload","path":"编程规范/C#转换方案.md","bytes":76079,"elapsedMs":26377,"success":false,"scope":"workspace"}
{"operation":"workspaceList","success":true}
切换完成后(远端实际只有 6 篇):
json
{"primaryBackupMethod":"github","syncedFileShas":9}
NoteGen 版本
NoteGenv0.39.0
操作系统
Windows
报错日志
No response
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 975
- Avg merge
- 20h 27m
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from codexu/note-gen
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 58/100
-
Difficulty 1/5 Under an hour Newbie friendliness 45/100
Similar issues
-
bug triage:in-progress
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
e2e-failure ready-to-code
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
redhat-developer/rhdh-plugin-export-overlays#4845 · 1 comment ·
Maintainers usually reply within 1 day
-
chore kaizen ui-rewrite
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
IBM/mcp-context-forge#7681 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
cloudflare/workers-sdk#17159 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
cybersemics/em#6398 ·
Maintainers usually reply within 1 day