dsh-unlag 1.9.26 → 1.9.27
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/index.js +18 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -31,6 +31,12 @@ export const inject = ['webServer']
|
|
|
31
31
|
|
|
32
32
|
/** A transaction that has not finished in this long is stuck; the press reports it instead of hanging. */
|
|
33
33
|
const RELOAD_TIMEOUT_MS = 20_000
|
|
34
|
+
/**
|
|
35
|
+
* How long a press waits for an answer before it is told the update is still applying. The page
|
|
36
|
+
* gives up on its own request sooner than the update may take, and a press that ends in "did not
|
|
37
|
+
* finish" while the plugin set is still being replaced is a lie the person cannot check.
|
|
38
|
+
*/
|
|
39
|
+
const RELOAD_ANSWER_MS = 10_000
|
|
34
40
|
|
|
35
41
|
|
|
36
42
|
const LOG_PATH = join(homedir(), '.dsh', 'unlag-reload.log')
|
|
@@ -1667,8 +1673,18 @@ function serveButton(ctx, controller, config) {
|
|
|
1667
1673
|
if (method !== 'POST') return sendJson(res, 405, { status: 'method' })
|
|
1668
1674
|
if (buttonAllowed(req) === false) return sendJson(res, 403, { status: 'forbidden' })
|
|
1669
1675
|
if (!settings.reloadPlugins) return sendJson(res, 200, { status: 'off' })
|
|
1670
|
-
const
|
|
1671
|
-
|
|
1676
|
+
const limit = Number(process.env.DSH_UNLAG_ANSWER_MS ?? '') || RELOAD_ANSWER_MS
|
|
1677
|
+
let timer = null
|
|
1678
|
+
const stillApplying = new Promise((resolve) => {
|
|
1679
|
+
timer = setTimeout(() => resolve({ status: 'applying', warnings: [], pending: [], restartReason: null, failedEntries: [] }), limit)
|
|
1680
|
+
})
|
|
1681
|
+
try {
|
|
1682
|
+
const outcome = await Promise.race([controller.reloadNow(), stillApplying])
|
|
1683
|
+
if (outcome?.status === 'applying') log('the update outlasted the answer the page waits for: the press is told it is still applying')
|
|
1684
|
+
sendJson(res, 200, outcome)
|
|
1685
|
+
} finally {
|
|
1686
|
+
if (timer !== null) clearTimeout(timer)
|
|
1687
|
+
}
|
|
1672
1688
|
} catch (error) {
|
|
1673
1689
|
log(`cannot apply a plugin reload: ${error?.message ?? error}`)
|
|
1674
1690
|
sendJson(res, 500, { status: 'failed', detail: String(error?.message ?? error) })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-unlag",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.27",
|
|
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",
|