bug: 关闭 Beta 频道后被自动降级到旧版本,导致本地库迁移失败、会话列表打不开
- Dominant language
- TypeScript
- Stars
- 2.7k
- Forks
- 395
- Avg merge
- 21h 48m
- Merged PRs (30d)
- 776
Description
**提交人**: Dong Wong
**客户端版本**: 0.1.64
---
## 现象
在 Beta 频道升级到 0.1.64 后关闭 Beta,更新器检测到 `current=0.1.64, latest=0.1.61` 仍提示 “Update available: 0.1.64 → 0.1.61”,把旧版 0.1.61 当作“新版本”降级安装;重启后本地库迁移失败(`MIGRATE_FAILED`),会话列表打不开。
## 实际行为
- updater 将 0.1.64 → 0.1.61 判定为“需要更新”并执行降级安装;
- 0.1.61 无法识别 0.1.64 迁移过的本地库,启动即报 `migrateFailed: applied migration runtime identity changed at seq 95`,随后 `fatal.rendererOwned code=MIGRATE_FAILED`,会话列表无法打开。
## 期望行为
- 更新仅在 `latest > current`(严格 semver 比较)时进行,禁止降级;
- 切换 beta ↔ release 频道若会引入降级,应显式拦截并提示用户;
- 旧版二进制遇到新 schema 时给出可恢复的错误指引。
## 根因推断
1. updater 版本判断只比较 `current != latest`,缺少 `latest > current` 的 semver 比较;
2. 0.1.64 已将本地库迁移到 96 个 migration,0.1.61 无法识别新 schema,启动即迁移失败;
3. release 频道最新版本低于当前版本时,每次检查更新都会反复降级(降级循环)。
## 复现步骤
1. 加入 Beta 频道并升级到 0.1.64(本地库迁移到最新 schema);
2. 关闭 Beta(更新源切到 release 频道);
3. 重启应用触发更新检查,updater 将 0.1.64 → 0.1.61 判定为“需要更新”并降级安装;
4. 再次重启:本地数据库 schema 迁移失败,会话列表打不开。
## 复现频率
每次按上述步骤操作均会复现;只要 release 最新版本仍低于当前版本,每次更新检查都会重复降级。
## 已尝试
将 `update-channel-settings.json` 中 `enableBeta` 改回 `true` 并重启,可回到 0.1.64、会话恢复;但这只是止血,release 频道追平 ≥0.1.64 之前不能安全关闭 Beta。
## 日志(脱敏关键行)
```
Version check: current=0.1.64, latest=0.1.61
Update available: 0.1.64 → 0.1.61
[localDb] migrateFailed: applied migration runtime identity changed at seq 95 (0095_scope_messages_fts_update_trigger.sql)
[localDb] fatal.rendererOwned code=MIGRATE_FAILED title="本地数据库 schema 迁移失败"
```
---
**OS**: darwin arm64 (27.0.0)
**界面语言**: en
Contributor guide
Research direction
Start at the updater's version-check path and inspect how update-channel-settings.json selects the Beta or release channel, then trace the localDb migration error path. Reproduce the 0.1.64-to-0.1.61 scenario and verify that lower versions are not installed, channel changes are handled explicitly, and migration failures provide recovery guidance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- electron, typescript
- Domain
- databases, desktop, release
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100