dsh-unlag 1.9.17 → 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 (2) hide show
  1. package/client.js +18 -3
  2. 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-unlag",
3
- "version": "1.9.17",
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",