dsh-unlag 1.9.16 → 1.9.18

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.
Files changed (3) hide show
  1. package/client.js +18 -3
  2. package/index.js +6 -0
  3. package/package.json +1 -1
package/client.js CHANGED
@@ -117,18 +117,33 @@ window.__ModuleLoader__.load({
117
117
  * before rebuilding looks exactly like one that never happened, and the page itself is gone by
118
118
  * the time anyone reads it.
119
119
  */
120
- function report(event, gate) {
120
+ function report(event, gate, attempt = 0) {
121
121
  const page = String(window?.__DSH_BOOT__?.rev ?? '').replace(/[^a-z0-9]/gu, '').slice(0, 24);
122
122
  const named = gate === undefined ? `event=${event}` : `event=${event}&gate=${encodeURIComponent(gate)}`;
123
123
  const query = page === '' ? named : `${named}&rev=${page}`;
124
+ /**
125
+ * The route belongs to the instance this press is replacing. Its answer can land while the old
126
+ * one is gone and the new one is not listening yet, and a lost line is a press nobody can
127
+ * account for later. Two more tries cost nothing and keep the record.
128
+ */
129
+ const again = () => {
130
+ if (attempt >= 2) return;
131
+ setTimeout(() => report(event, gate, attempt + 1), attempt === 0 ? 300 : 900);
132
+ };
124
133
  try {
125
134
  fetch(`${HOST_BASE}/report?${query}`, {
126
135
  method: 'POST', // ui-copy-ignore
127
136
  credentials: 'same-origin',
128
137
  headers: { 'x-dsh-unlag': '1' }, // ui-copy-ignore
129
138
  keepalive: true, // ui-copy-ignore
130
- }).catch(() => {});
131
- } catch {}
139
+ })
140
+ .then((response) => {
141
+ if (!response?.ok) again();
142
+ })
143
+ .catch(again);
144
+ } catch {
145
+ again();
146
+ }
132
147
  }
133
148
 
134
149
  /** Ask the running app to replace changed plugins now; a running turn is reported, never cut. */
package/index.js CHANGED
@@ -386,6 +386,12 @@ function pluginReloader(ctx, config) {
386
386
  log(
387
387
  `plugins reloaded (warnings=${warnings.length} pending=${pending.length}${restartReason === null ? '' : ` restart=${restartReason}`})`,
388
388
  )
389
+ /**
390
+ * The count alone cannot say which plugin is not serving now, and that is what a person sees
391
+ * afterwards. The app's own sentence is passed on, cut short so one entry cannot fill the log.
392
+ */
393
+ for (const entry of failedEntries.slice(0, 5)) log(`a plugin did not come back: ${entry.slice(0, 200)}`)
394
+ if (failedEntries.length > 5) log(`and ${failedEntries.length - 5} more did not come back`)
389
395
  return { status: 'done', warnings, pending, restartReason, failedEntries }
390
396
  }
391
397
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-unlag",
3
- "version": "1.9.16",
3
+ "version": "1.9.18",
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",