@jsenv/core 41.4.19 → 41.4.20

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.
@@ -178,11 +178,19 @@ const setup = () => {
178
178
  // only carries the id, tab, activities and log entries.
179
179
  let pendingLogs = [];
180
180
  let pendingActivities = [];
181
+ // The server answering that the endpoint does not exist means there is no
182
+ // monitoring behind this origin anymore (the dev server was restarted
183
+ // without it, a test server took the port): reporting stops for the rest of
184
+ // this page's life rather than knocking at every heartbeat.
185
+ let endpointGone = false;
181
186
  const post = async ({ beacon = false, closing = false } = {}) => {
182
187
  const logs = pendingLogs;
183
188
  const activities = pendingActivities;
184
189
  pendingLogs = [];
185
190
  pendingActivities = [];
191
+ if (endpointGone) {
192
+ return;
193
+ }
186
194
  const payload = JSON.stringify({
187
195
  clientId,
188
196
  // The server reads browser/OS from the request headers, but a headless
@@ -201,12 +209,15 @@ const setup = () => {
201
209
  return;
202
210
  }
203
211
  try {
204
- await nativeFetch(REPORT_ENDPOINT, {
212
+ const response = await nativeFetch(REPORT_ENDPOINT, {
205
213
  method: "POST",
206
214
  headers: { "content-type": "application/json" },
207
215
  body: payload,
208
216
  keepalive: true,
209
217
  });
218
+ if (response.status === 404 || response.status === 405) {
219
+ endpointGone = true;
220
+ }
210
221
  } catch {
211
222
  // dev server gone or offline — dropping the report is acceptable.
212
223
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "41.4.19",
3
+ "version": "41.4.20",
4
4
  "type": "module",
5
5
  "description": "Tool to develop, test and build js projects",
6
6
  "repository": {
@@ -78,7 +78,7 @@
78
78
  "@jsenv/plugin-minification": "1.7.10",
79
79
  "@jsenv/plugin-supervisor": "1.8.13",
80
80
  "@jsenv/plugin-transpilation": "1.6.1",
81
- "@jsenv/server": "17.6.2",
81
+ "@jsenv/server": "17.6.3",
82
82
  "@jsenv/sourcemap": "1.4.2",
83
83
  "react-table": "7.8.0"
84
84
  },
@@ -178,11 +178,19 @@ const setup = () => {
178
178
  // only carries the id, tab, activities and log entries.
179
179
  let pendingLogs = [];
180
180
  let pendingActivities = [];
181
+ // The server answering that the endpoint does not exist means there is no
182
+ // monitoring behind this origin anymore (the dev server was restarted
183
+ // without it, a test server took the port): reporting stops for the rest of
184
+ // this page's life rather than knocking at every heartbeat.
185
+ let endpointGone = false;
181
186
  const post = async ({ beacon = false, closing = false } = {}) => {
182
187
  const logs = pendingLogs;
183
188
  const activities = pendingActivities;
184
189
  pendingLogs = [];
185
190
  pendingActivities = [];
191
+ if (endpointGone) {
192
+ return;
193
+ }
186
194
  const payload = JSON.stringify({
187
195
  clientId,
188
196
  // The server reads browser/OS from the request headers, but a headless
@@ -201,12 +209,15 @@ const setup = () => {
201
209
  return;
202
210
  }
203
211
  try {
204
- await nativeFetch(REPORT_ENDPOINT, {
212
+ const response = await nativeFetch(REPORT_ENDPOINT, {
205
213
  method: "POST",
206
214
  headers: { "content-type": "application/json" },
207
215
  body: payload,
208
216
  keepalive: true,
209
217
  });
218
+ if (response.status === 404 || response.status === 405) {
219
+ endpointGone = true;
220
+ }
210
221
  } catch {
211
222
  // dev server gone or offline — dropping the report is acceptable.
212
223
  }