dsh-config-sync-plugin 0.4.2 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en.md CHANGED
@@ -257,6 +257,10 @@ Two display fixes on top of 0.3.77:
257
257
 
258
258
  The "Plugin update" card now shows an **npm download URL** line with the actual fallback addresses (domestic mirror `registry.npmmirror.com` + official `registry.npmjs.org`). When the GitHub release download is unreachable (common in mainland China), the update package automatically falls back to npm. It is still verified against the authoritative sha256 in `version.json` — switching source never relaxes verification. The two sources back each other up: the mirror can briefly 404 during its first-sync window, and the official source takes over. The npm tarball is byte-identical to the GitHub release tgz (same sha256).
259
259
 
260
+ ### Fix watcher stuck in wait after × close due to orphan process (0.4.04)
261
+
262
+ After clicking × the push watcher gets queued but can stall in wait. Root cause: when WatchPid is force-killed it often leaves a **windowless orphan DSH child** (started before the watcher, parent dead). The stale-watcher check required "all DSH processes newer than the watcher", which this orphan permanently broke — `newerAll.Count ≠ byName.Count`, so the watcher idled 30 min holding `auto-sync.lock` and no new watcher could take over. The check now looks for "a DSH instance older than the watcher WITH a foreground window": the real signal that "the queued DSH is still in use" is a windowed instance; windowless leftovers and new instances no longer block handoff, and the watcher exits 3 to clear the lock immediately. Selftest assertion added.
263
+
260
264
  ### npm fallback version normalization fix (0.4.02)
261
265
 
262
266
  npm normalizes `0.4.01` to `0.4.1` per semver, so the tarball is `dsh-config-sync-plugin-0.4.1.tgz`. Before 0.4.02 the fallback URL was built as `-0.4.01.tgz`, which 404s on npm. `npmTgzUrls` now strips leading zeros from numeric segments (`0.4.01`→`0.4.1`) before building the URL; GitHub release and version.json keep the user-specified version (same artifact, identical sha256). Selftest assertion added.
@@ -781,6 +785,8 @@ The log shows which path ran: `文件比较(快筛):比对 N 个,深哈
781
785
 
782
786
  | Date | Version | Summary |
783
787
  |---|---|---|
788
+ | 2026-11-25 | 0.4.04 | Fix watcher stuck in wait after × close due to windowless orphan process: stale check now looks for a leftover foreground window, clears lock and hands over immediately |
789
+ | 2026-11-25 | 0.4.03 | Repackaged release: code identical to 0.4.02; only version and release metadata updated to 0.4.03 |
784
790
  | 2026-11-25 | 0.4.02 | Fix npm fallback version normalization: npm semver turns 0.4.01 into 0.4.1; strip leading zeros when building tarball URL, otherwise 404 |
785
791
  | 2026-11-25 | 0.4.01 | Auto sync only on active × close: scheduleAutoStart updates drift status only, handleSettings queues watcher without close, only × close/pagehide (shouldCloseDsh:true) actually closes DSH after queuing |
786
792
  | 2026-11-25 | 0.3.99 | Toggle auto-pull/push now triggers immediate sync check (core logic checkAndQueueAutoSync reused by scheduleAutoStart/triggerAutoSyncOnClose/handleSettings; toggle change queues immediately, manual-trigger mode skips confirm) |
package/README.md CHANGED
@@ -277,6 +277,10 @@ pwsh -File runtime\sync.ps1 pull `
277
277
 
278
278
  「插件更新」卡新增一行 **npm 下载路径**,直接显示实际兜底地址(国内镜像 `registry.npmmirror.com` + 官方 `registry.npmjs.org` 两个源)。GitHub release 整段不通时(国内常见),更新包会自动兜底从 npm 下载;仍按 `version.json` 里的权威 sha256 校验,换源不放宽校验。两个源互为备份:镜像首发同步窗口期会短暂 404,官方源随即兜上。实测 npm tarball 与 GitHub release tgz 是同一份产物、sha256 完全一致。
279
279
 
280
+ ### 修复点 × 关闭后 watcher 被孤儿进程卡在 wait(0.4.04)
281
+
282
+ 点 × 关闭后 push watcher 已经排上,但可能卡在 wait 阶段迟迟不执行。根因:`WatchPid` 被强杀后,常留下一个**无前台窗口的孤儿 DSH 子进程**(启动时间比 watcher 还早,父进程已死)。僵死 watcher 自清的旧判据要求「所有现存 DSH 都比 watcher 新」,这个孤儿进程把它永久破坏——`newerAll.Count ≠ byName.Count`,watcher 死等 30 分钟还霸占 `auto-sync.lock`,新 watcher 也没法接管。判定改成「有没有比 watcher 更早、且有前台窗口的 DSH 实例」:真正代表「排队那次 DSH 还在用」的是有窗口的实例;无窗口残留和新实例都不该挡住让位,watcher 立即 `exit 3` 清锁让新 watcher 接管。selftest 加断言防回归。
283
+
280
284
  ### npm 兜底下载的版本规范化修复(0.4.02)
281
285
 
282
286
  npm 按 semver 把版本号 `0.4.01` 规范化成 `0.4.1`,tarball 文件名是 `dsh-config-sync-plugin-0.4.1.tgz`。0.4.01 之前拼的是 `-0.4.01.tgz`,npm 兜底下载会 404。`npmTgzUrls` 现在对数字段去前导零(`0.4.01`→`0.4.1`)再拼 URL;GitHub release 与 version.json 仍保留用户指定的版本号(同一份产物、sha256 一致)。selftest 加断言防回归。
@@ -763,6 +767,8 @@ pwsh -File sync.ps1 push -ScanHistory
763
767
 
764
768
  | 日期 | 版本 | 要点 |
765
769
  |---|---|---|
770
+ | 2026-11-25 | 0.4.04 | 修复点 × 关闭后 push watcher 被无窗口孤儿进程卡在 wait 不执行:过期判定改看有无遗留前台窗口,立即清锁让位 |
771
+ | 2026-11-25 | 0.4.03 | 重新打包发布:代码与 0.4.02 一致,仅版本与发布元数据更新到 0.4.03 |
766
772
  | 2026-11-25 | 0.4.02 | 修复 npm 兜底下载的版本规范化:0.4.01 被 npm semver 规范化成 0.4.1,拼 tarball 时去前导零,否则 404 |
767
773
  | 2026-11-25 | 0.4.01 | 自动同步仅在主动关闭 DSH 窗口(×)时触发:scheduleAutoStart 只做 drift 状态更新,handleSettings 只排队不退出,只有 × 关闭/页面卸载走 shouldCloseDsh: true 真正关闭 DSH |
768
774
  | 2026-11-25 | 0.3.99 | 勾选自动同步开关即时触发判断(核心逻辑抽离为 checkAndQueueAutoSync,scheduleAutoStart/triggerAutoSyncOnClose/handleSettings 三路复用,开关变更即时排队,手动模式跳过确认框) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-config-sync-plugin",
3
- "version": "0.4.02",
3
+ "version": "0.4.04",
4
4
  "type": "module",
5
5
  "description": "在 DSH 设置里查看 dsh-config 仓库与本机的同步状态,并生成退出后执行的 push/pull 脚本。同步动作本身不在应用内执行。面板与文案跟随客户端语言(中文/English)。",
6
6
  "main": "./index.js",
@@ -73,9 +73,14 @@ if ($Phase -eq 'wait') {
73
73
  if ($WatchPid -gt 0 -and -not $byPid -and $byName.Count -gt 0) {
74
74
  $myStart = (Get-Process -Id $PID -ErrorAction SilentlyContinue).StartTime
75
75
  if ($myStart) {
76
- $newerAll = @($byName | Where-Object { $_.StartTime -and $_.StartTime -ge $myStart })
77
- if ($newerAll.Count -eq $byName.Count) {
78
- WaitLog ('WatchPid {0} 已退出,现存 DSH 均为本等待启动后的新实例,判定为过期 watcher,退出让位' -f $WatchPid)
76
+ # 0.4.04:原判据「所有 DSH 都比 watcher 新」会被**无窗口的孤儿进程**破坏——
77
+ # 实测 WatchPid 被强杀后留下一个比 watcher 还早启动的子进程(父已死、hwnd=0),
78
+ # 它既不是用户在用的实例、也不会消失,把 newerAll.Count -eq byName.Count 永远卡死,
79
+ # watcher 死等 30 分钟还霸占 auto-sync.lock。真正代表「排队那次 DSH 还在用」的,
80
+ # 是比 watcher 早启动**且有前台窗口**的实例;无窗口残留/新实例都不该挡住让位。
81
+ $visibleOld = @($byName | Where-Object { $_.MainWindowHandle -ne 0 -and $_.StartTime -and $_.StartTime -lt $myStart })
82
+ if ($visibleOld.Count -eq 0) {
83
+ WaitLog ('WatchPid {0} 已退出,无遗留前台窗口(现存为残留进程或新实例),判定为过期 watcher,退出让位' -f $WatchPid)
79
84
  try {
80
85
  $lockFile = Join-Path $DshHome 'auto-sync.lock'
81
86
  if (Test-Path -LiteralPath $lockFile) {
@@ -1830,6 +1830,10 @@ console.log('== 0.3.94:清理跨重启僵死 watcher,锁不再被旧实例
1830
1830
  check('post-exit wait:WatchPid 已死但进程名有新实例时判定过期 watcher',
1831
1831
  postSrc.includes('-not $byPid -and $byName.Count -gt 0')
1832
1832
  && postSrc.includes('判定为过期 watcher'), 'post-exit.ps1 过期判定')
1833
+ check('0.4.04:过期判定改为看有无遗留前台窗口,不被无窗口孤儿进程卡死',
1834
+ postSrc.includes('$visibleOld = @($byName | Where-Object { $_.MainWindowHandle -ne 0')
1835
+ && postSrc.includes('$visibleOld.Count -eq 0')
1836
+ && postSrc.includes('无遗留前台窗口'), 'post-exit.ps1 孤儿进程让位')
1833
1837
  check('post-exit wait:过期 watcher 清自己的锁并 exit 3 让位',
1834
1838
  /\$lock\.pid -eq \$PID/.test(postSrc) && /\bexit 3\b/.test(postSrc), 'post-exit.ps1 让位')
1835
1839
  }