dsh-unlag 1.9.30 → 1.9.32
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.md +1 -1
- package/index.js +20 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ dsh plugin install dsh-unlag
|
|
|
70
70
|
## 排错
|
|
71
71
|
|
|
72
72
|
- 日志:`~/.dsh/unlag-reload.log`,换代码/跳过/被拦各一行,含原因。
|
|
73
|
-
- 状态:`GET /dsh-unlag/state` → `{"version":"
|
|
73
|
+
- 状态:`GET /dsh-unlag/state` → `{"version":"<当前版本>","code":"<index.js 写入时间>","plugins":true,"page":true,"shim":{...}}`。`code` 用来分清「版本号没刷」和「旧代码真的还在跑」。
|
|
74
74
|
- 重建后的日志带起页面代次:`interface rebuilt; the page runs the plugins as served now (page <rev>)`,据此判断新文档加载的是新脚本还是旧脚本。
|
|
75
75
|
|
|
76
76
|
## 测试
|
package/index.js
CHANGED
|
@@ -1678,9 +1678,27 @@ function serveButton(ctx, controller, config) {
|
|
|
1678
1678
|
const stillApplying = new Promise((resolve) => {
|
|
1679
1679
|
timer = setTimeout(() => resolve({ status: 'applying', warnings: [], pending: [], restartReason: null, failedEntries: [] }), limit)
|
|
1680
1680
|
})
|
|
1681
|
+
let answeredEarly = false
|
|
1681
1682
|
try {
|
|
1682
|
-
const
|
|
1683
|
-
|
|
1683
|
+
const work = controller.reloadNow()
|
|
1684
|
+
/**
|
|
1685
|
+
* The answer the page waits for is bounded, but the update is not. Whatever the update
|
|
1686
|
+
* did after the page was told it is still applying is written down here: a replacement
|
|
1687
|
+
* that failed a moment later must not look like one that succeeded.
|
|
1688
|
+
*/
|
|
1689
|
+
work.then(
|
|
1690
|
+
(late) => {
|
|
1691
|
+
if (answeredEarly) log(`the update finished after the page was told it is still applying: ${String(late?.status ?? 'no status')}`)
|
|
1692
|
+
},
|
|
1693
|
+
(error) => {
|
|
1694
|
+
if (answeredEarly) log(`the update failed after the page was told it is still applying: ${error?.message ?? error}`)
|
|
1695
|
+
},
|
|
1696
|
+
)
|
|
1697
|
+
const outcome = await Promise.race([work, stillApplying])
|
|
1698
|
+
if (outcome?.status === 'applying') {
|
|
1699
|
+
answeredEarly = true
|
|
1700
|
+
log('the update outlasted the answer the page waits for: the press is told it is still applying')
|
|
1701
|
+
}
|
|
1684
1702
|
sendJson(res, 200, outcome)
|
|
1685
1703
|
} finally {
|
|
1686
1704
|
if (timer !== null) clearTimeout(timer)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-unlag",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.32",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A press applies plugin edits right away and brings a laggy interface back; automatic reloading stays off unless you turn it on, so the press is the only trigger, and nothing restarts.",
|
|
6
6
|
"license": "MIT",
|