@wix/origami-site 1.3.8 → 1.3.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/origami-site",
3
- "version": "1.3.8",
3
+ "version": "1.3.9",
4
4
  "description": "Runs an exported Wix origami site: file-based routing, Wix dynamic pages, popups and build checks. Use with @wix/origami-site-astro or @wix/origami-site-express.",
5
5
  "type": "module",
6
6
  "files": [
@@ -48,11 +48,11 @@
48
48
  "dependencies": {
49
49
  "@wix/origami-types": "^2.0.1",
50
50
  "@wix/builder-error-pages": "^1.1.6",
51
- "@wix/origami-transforms": "^0.1.79",
51
+ "@wix/origami-transforms": "^0.1.80",
52
52
  "@babel/parser": "^7.25.0",
53
53
  "@wix/origami-services": "^1.5.6",
54
54
  "@wix/services-manager-react": "^1.0.8",
55
- "@wix/origami-bi": "^0.24.11"
55
+ "@wix/origami-bi": "^0.24.12"
56
56
  },
57
57
  "exports": {
58
58
  "./server": {
@@ -93,5 +93,5 @@
93
93
  "optional": true
94
94
  }
95
95
  },
96
- "falconPackageHash": "b097acd7547aa85dc94cca8dbdc751a3fae0525d48ce82e997a50d07"
96
+ "falconPackageHash": "9aa2d72f86a278c3547467339792fc7233569fd5cb502a9e33a88fd3"
97
97
  }
@@ -1,4 +1,4 @@
1
- import { currentRow } from '@wix/origami-bi'
1
+ import { currentRow, devCounts, takeDevCounts } from '@wix/origami-bi'
2
2
 
3
3
  const key = Symbol.for('@wix/origami-site/request-bi/v1')
4
4
  /** Counters are shared by core reloads and embeds within the same workspace run. */
@@ -8,14 +8,15 @@ export function requestCounts() {
8
8
  const summaries = globalThis[key] ??= new WeakMap()
9
9
  let counts = summaries.get(run)
10
10
  if (!counts) {
11
- counts = { requests: {}, router_errors: {}, embed_fetch_failures: 0 }
11
+ counts = { requests: {}, router_errors: {}, embed_fetch_failures: 0, session: devCounts(run) }
12
12
  summaries.set(run, counts)
13
- let serverErrors = 0
14
13
  const emit = () => {
15
- if (!Object.keys(counts.requests).length && !Object.keys(counts.router_errors).length && !counts.embed_fetch_failures) return
16
- for (const [request, count] of Object.entries(counts.requests)) if (request.endsWith('_500')) serverErrors += count
14
+ const session = takeDevCounts(run)
15
+ // A minute with nothing new sends nothing; a session count that changed (an HMR update, a transform error) is activity.
16
+ if (!Object.keys(counts.requests).length && !Object.keys(counts.router_errors).length && !counts.embed_fetch_failures && !session.changed) return
17
+ // A heartbeat: the session's counts so far, so the last one a killed server sent still has them.
17
18
  run.commandRow.runInContext(() => run.openRow('step', 'request', { step_details: {
18
- requests: { ...counts.requests }, router_errors: { ...counts.router_errors }, embed_fetch_failures: counts.embed_fetch_failures,
19
+ requests: { ...counts.requests }, router_errors: { ...counts.router_errors }, embed_fetch_failures: counts.embed_fetch_failures, ...session.counts,
19
20
  } }).end())
20
21
  counts.requests = {}; counts.router_errors = {}; counts.embed_fetch_failures = 0
21
22
  }
@@ -28,14 +29,20 @@ export function requestCounts() {
28
29
  run.onFinish?.(() => {
29
30
  clearInterval(timer)
30
31
  emit()
31
- run.commandRow.update({ step_details: { server_errors: serverErrors } })
32
32
  })
33
33
  }
34
34
  return counts
35
35
  }
36
36
 
37
+ /** One answered request, by kind and status; a 500 also counts in the session's `server_errors_count`.
38
+ * @param {NonNullable<ReturnType<typeof requestCounts>>} counts @param {string} request */
39
+ export function countRequest(counts, request) {
40
+ counts.requests[request] = (counts.requests[request] ?? 0) + 1
41
+ if (request.endsWith('_500')) counts.session.server_errors_count++
42
+ }
43
+
37
44
  /** A page the server couldn't render (SSR) or a site it couldn't load: the 500 the bridge sends. */
38
45
  export function countServerError() {
39
46
  const counts = requestCounts()
40
- if (counts) counts.requests.ssr_500 = (counts.requests.ssr_500 ?? 0) + 1
47
+ if (counts) countRequest(counts, 'ssr_500')
41
48
  }
@@ -1,4 +1,4 @@
1
- import { requestCounts } from './bi.js'
1
+ import { countRequest, requestCounts } from './bi.js'
2
2
  import { createSiteTree } from '../site-tree/createSiteTree.js'
3
3
  import { readSiteTree } from '../site-tree/readSiteTree.js'
4
4
  import { callRouter } from '../router/index.js'
@@ -179,10 +179,7 @@ export async function createSite(options) {
179
179
  return resolution
180
180
  } catch (error) { return errorPage(error, 500, mode, logger) }
181
181
  finally {
182
- if (bi) {
183
- const key = `${kind}_${status}`
184
- bi.requests[key] = (bi.requests[key] ?? 0) + 1
185
- }
182
+ if (bi) countRequest(bi, `${kind}_${status}`)
186
183
  }
187
184
  },
188
185
  }