@jsenv/core 27.5.2 → 27.5.3

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.
@@ -131,7 +131,8 @@ const formatError = (error, {
131
131
  // so use it only when error.stack is not available
132
132
 
133
133
 
134
- if (url && !stack) {
134
+ if (url && !stack && // ignore window.reportError() it gives no valuable info
135
+ !url.endsWith("html_supervisor_installer.js")) {
135
136
  onErrorLocated(resolveUrlSite({
136
137
  url,
137
138
  line,
@@ -358,6 +359,7 @@ const link = ({
358
359
  }) => `<a href="${href}">${text}</a>`;
359
360
 
360
361
  const JSENV_ERROR_OVERLAY_TAGNAME = "jsenv-error-overlay";
362
+ let previousErrorInfo = null;
361
363
  const displayErrorInDocument = (error, {
362
364
  rootDirectoryUrl,
363
365
  errorBaseUrl,
@@ -369,6 +371,22 @@ const displayErrorInDocument = (error, {
369
371
  reportedBy,
370
372
  requestedRessource
371
373
  }) => {
374
+ const nowMs = Date.now(); // ensure error dispatched on window by browser is displayed first
375
+ // then the server error replaces it (because it contains more information)
376
+
377
+ if (previousErrorInfo) {
378
+ const previousErrorReportedBy = previousErrorInfo.reportedBy;
379
+ const msEllapsedSincePreviousError = nowMs - previousErrorInfo.ms;
380
+
381
+ if (previousErrorReportedBy === "server" && reportedBy === "browser" && msEllapsedSincePreviousError < 50) {
382
+ return () => {};
383
+ }
384
+ }
385
+
386
+ previousErrorInfo = {
387
+ ms: nowMs,
388
+ reportedBy
389
+ };
372
390
  const {
373
391
  theme,
374
392
  title,
@@ -815,15 +833,18 @@ const installHtmlSupervisor = ({
815
833
  }
816
834
 
817
835
  const {
818
- error
836
+ error,
837
+ filename,
838
+ lineno,
839
+ colno
819
840
  } = errorEvent;
820
841
  displayErrorInDocument(error, {
821
842
  rootDirectoryUrl,
822
843
  errorBaseUrl,
823
844
  openInEditor,
824
- url: errorEvent.filename,
825
- line: errorEvent.lineno,
826
- column: errorEvent.colno,
845
+ url: filename,
846
+ line: lineno,
847
+ column: colno,
827
848
  reportedBy: "browser"
828
849
  });
829
850
  });
@@ -864,27 +885,22 @@ const installHtmlSupervisor = ({
864
885
 
865
886
  if (isFaviconAutoRequest) {
866
887
  return;
867
- } // setTimeout is to ensure the error
868
- // dispatched on window by browser is displayed first,
869
- // then the server error replaces it (because it contains more information)
870
-
871
-
872
- setTimeout(() => {
873
- displayErrorInDocument({
874
- message,
875
- stack
876
- }, {
877
- rootDirectoryUrl,
878
- errorBaseUrl,
879
- openInEditor,
880
- url: traceUrl,
881
- line: traceLine,
882
- column: traceColumn,
883
- codeFrame: traceMessage,
884
- reportedBy: "server",
885
- requestedRessource
886
- });
887
- }, 10);
888
+ }
889
+
890
+ displayErrorInDocument({
891
+ message,
892
+ stack
893
+ }, {
894
+ rootDirectoryUrl,
895
+ errorBaseUrl,
896
+ openInEditor,
897
+ url: traceUrl,
898
+ line: traceLine,
899
+ column: traceColumn,
900
+ codeFrame: traceMessage,
901
+ reportedBy: "server",
902
+ requestedRessource
903
+ });
888
904
  }
889
905
  });
890
906
  }
package/dist/main.js CHANGED
@@ -25715,7 +25715,7 @@ const executeTestPlan = async ({
25715
25715
  keepRunning = false,
25716
25716
  cooldownBetweenExecutions = 0,
25717
25717
  gcBetweenExecutions = logMemoryHeapUsage,
25718
- coverageEnabled = process.argv.includes("--cover") || process.argv.includes("--coverage"),
25718
+ coverageEnabled = process.argv.includes("--coverage"),
25719
25719
  coverageConfig = {
25720
25720
  "./src/": true
25721
25721
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "27.5.2",
3
+ "version": "27.5.3",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -103,7 +103,12 @@ export const formatError = (
103
103
 
104
104
  // error.stack is more reliable than url/line/column reported on window error events
105
105
  // so use it only when error.stack is not available
106
- if (url && !stack) {
106
+ if (
107
+ url &&
108
+ !stack &&
109
+ // ignore window.reportError() it gives no valuable info
110
+ !url.endsWith("html_supervisor_installer.js")
111
+ ) {
107
112
  onErrorLocated(resolveUrlSite({ url, line, column }))
108
113
  }
109
114
 
@@ -2,6 +2,8 @@ import { formatError } from "./error_formatter.js"
2
2
 
3
3
  const JSENV_ERROR_OVERLAY_TAGNAME = "jsenv-error-overlay"
4
4
 
5
+ let previousErrorInfo = null
6
+
5
7
  export const displayErrorInDocument = (
6
8
  error,
7
9
  {
@@ -16,6 +18,25 @@ export const displayErrorInDocument = (
16
18
  requestedRessource,
17
19
  },
18
20
  ) => {
21
+ const nowMs = Date.now()
22
+ // ensure error dispatched on window by browser is displayed first
23
+ // then the server error replaces it (because it contains more information)
24
+ if (previousErrorInfo) {
25
+ const previousErrorReportedBy = previousErrorInfo.reportedBy
26
+ const msEllapsedSincePreviousError = nowMs - previousErrorInfo.ms
27
+ if (
28
+ previousErrorReportedBy === "server" &&
29
+ reportedBy === "browser" &&
30
+ msEllapsedSincePreviousError < 50
31
+ ) {
32
+ return () => {}
33
+ }
34
+ }
35
+ previousErrorInfo = {
36
+ ms: nowMs,
37
+ reportedBy,
38
+ }
39
+
19
40
  const { theme, title, text, codeFramePromise, tip } = formatError(error, {
20
41
  rootDirectoryUrl,
21
42
  errorBaseUrl,
@@ -225,14 +225,14 @@ export const installHtmlSupervisor = ({
225
225
  // ignore custom error event (not sent by browser)
226
226
  return
227
227
  }
228
- const { error } = errorEvent
228
+ const { error, filename, lineno, colno } = errorEvent
229
229
  displayErrorInDocument(error, {
230
230
  rootDirectoryUrl,
231
231
  errorBaseUrl,
232
232
  openInEditor,
233
- url: errorEvent.filename,
234
- line: errorEvent.lineno,
235
- column: errorEvent.colno,
233
+ url: filename,
234
+ line: lineno,
235
+ column: colno,
236
236
  reportedBy: "browser",
237
237
  })
238
238
  })
@@ -252,7 +252,6 @@ export const installHtmlSupervisor = ({
252
252
  }
253
253
  return false
254
254
  }
255
-
256
255
  window.__server_events__.addEventCallbacks({
257
256
  error_while_serving_file: (serverErrorEvent) => {
258
257
  if (!isExecuting()) {
@@ -271,28 +270,23 @@ export const installHtmlSupervisor = ({
271
270
  if (isFaviconAutoRequest) {
272
271
  return
273
272
  }
274
- // setTimeout is to ensure the error
275
- // dispatched on window by browser is displayed first,
276
- // then the server error replaces it (because it contains more information)
277
- setTimeout(() => {
278
- displayErrorInDocument(
279
- {
280
- message,
281
- stack,
282
- },
283
- {
284
- rootDirectoryUrl,
285
- errorBaseUrl,
286
- openInEditor,
287
- url: traceUrl,
288
- line: traceLine,
289
- column: traceColumn,
290
- codeFrame: traceMessage,
291
- reportedBy: "server",
292
- requestedRessource,
293
- },
294
- )
295
- }, 10)
273
+ displayErrorInDocument(
274
+ {
275
+ message,
276
+ stack,
277
+ },
278
+ {
279
+ rootDirectoryUrl,
280
+ errorBaseUrl,
281
+ openInEditor,
282
+ url: traceUrl,
283
+ line: traceLine,
284
+ column: traceColumn,
285
+ codeFrame: traceMessage,
286
+ reportedBy: "server",
287
+ requestedRessource,
288
+ },
289
+ )
296
290
  },
297
291
  })
298
292
  }
@@ -60,8 +60,7 @@ export const executeTestPlan = async ({
60
60
  cooldownBetweenExecutions = 0,
61
61
  gcBetweenExecutions = logMemoryHeapUsage,
62
62
 
63
- coverageEnabled = process.argv.includes("--cover") ||
64
- process.argv.includes("--coverage"),
63
+ coverageEnabled = process.argv.includes("--coverage"),
65
64
  coverageConfig = {
66
65
  "./src/": true,
67
66
  },