@platformatic/runtime 3.51.0 → 3.52.1

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/lib/config.js CHANGED
@@ -142,9 +142,17 @@ export async function wrapInRuntimeConfig (config, context) {
142
142
  // on purpose, the package.json might be missing
143
143
  }
144
144
 
145
- // If the application supports its (so far, only @platformatic/service and descendants)
146
- const { hostname, port, http2, https } = config.server ?? {}
147
- const server = { hostname, port, http2, https }
145
+ // Carry over only the server properties that the user actually set, so
146
+ // we do not end up with a `{ hostname: undefined, ... }` object that then
147
+ // gets populated by schema defaults or trips truthy checks downstream.
148
+ const server = {}
149
+ if (config.server) {
150
+ for (const key of ['hostname', 'port', 'http2', 'https']) {
151
+ if (config.server[key] !== undefined) {
152
+ server[key] = config.server[key]
153
+ }
154
+ }
155
+ }
148
156
  const production = context?.isProduction ?? context?.production
149
157
 
150
158
  const runtimeConfig = config.runtime ?? {}
@@ -153,7 +161,7 @@ export async function wrapInRuntimeConfig (config, context) {
153
161
  /* c8 ignore next */
154
162
  const wrapped = {
155
163
  $schema: schema.$id,
156
- server,
164
+ ...(Object.keys(server).length > 0 ? { server } : {}),
157
165
  watch: !production,
158
166
  ...omitProperties(runtimeConfig, runtimeUnwrappablePropertiesList),
159
167
  entrypoint: applicationId,
package/lib/runtime.js CHANGED
@@ -73,8 +73,6 @@ import {
73
73
 
74
74
  const kWorkerFile = join(import.meta.dirname, 'worker/main.js')
75
75
  const kInspectorOptions = Symbol('plt.runtime.worker.inspectorOptions')
76
- const kHeapCheckCounter = Symbol('plt.runtime.worker.heapCheckCounter')
77
- const kLastHeapStats = Symbol('plt.runtime.worker.lastHeapStats')
78
76
 
79
77
  const MAX_LISTENERS_COUNT = 100
80
78
 
@@ -1518,28 +1516,17 @@ export class Runtime extends EventEmitter {
1518
1516
  }
1519
1517
 
1520
1518
  async getWorkerHealth (worker, options = {}) {
1521
- const currentELU = worker.performance.eventLoopUtilization()
1522
- const previousELU = options.previousELU
1519
+ // Use ITC to get health from the worker. This correctly forwards to child
1520
+ // processes when the service uses startWithCommand (subprocess mode),
1521
+ // instead of reading the coordinator thread's metrics.
1522
+ const { currentELU, heapUsed, heapTotal } = await sendViaITC(worker, 'getHealth')
1523
1523
 
1524
+ const previousELU = options.previousELU
1524
1525
  let elu = currentELU
1525
1526
  if (previousELU) {
1526
- elu = worker.performance.eventLoopUtilization(elu, previousELU)
1527
- }
1528
-
1529
- if (!features.node.worker.getHeapStatistics) {
1530
- return { elu: elu.utilization, currentELU }
1527
+ elu = performance.eventLoopUtilization(currentELU, previousELU)
1531
1528
  }
1532
1529
 
1533
- // Only check heap statistics every 60 health checks (once per minute)
1534
- const counter = (worker[kHeapCheckCounter] ?? 0) + 1
1535
- worker[kHeapCheckCounter] = counter >= 60 ? 0 : counter
1536
-
1537
- if (counter >= 60 || !worker[kLastHeapStats]) {
1538
- const { used_heap_size: heapUsed, total_heap_size: heapTotal } = await worker.getHeapStatistics()
1539
- worker[kLastHeapStats] = { heapUsed, heapTotal }
1540
- }
1541
-
1542
- const { heapUsed, heapTotal } = worker[kLastHeapStats]
1543
1530
  return { elu: elu.utilization, heapUsed, heapTotal, currentELU }
1544
1531
  }
1545
1532
 
@@ -1741,6 +1728,11 @@ export class Runtime extends EventEmitter {
1741
1728
  index,
1742
1729
  count: workersCount
1743
1730
  },
1731
+ resourceLimits: {
1732
+ maxOldGenerationSizeMb,
1733
+ maxYoungGenerationSizeMb,
1734
+ codeRangeSizeMb
1735
+ },
1744
1736
  inspectorOptions,
1745
1737
  dirname: this.#root
1746
1738
  },
@@ -45,7 +45,6 @@ export class Controller extends EventEmitter {
45
45
  #fileWatcher
46
46
  #debouncedRestart
47
47
  #context
48
- #lastELU
49
48
 
50
49
  constructor (runtimeConfig, applicationConfig, workerId, serverConfig, metricsConfig) {
51
50
  super()
@@ -59,7 +58,6 @@ export class Controller extends EventEmitter {
59
58
  this.#listening = false
60
59
  this.capability = null
61
60
  this.#fileWatcher = null
62
- this.#lastELU = performance.eventLoopUtilization()
63
61
 
64
62
  this.#context = {
65
63
  controller: this,
@@ -74,6 +72,7 @@ export class Controller extends EventEmitter {
74
72
  metricsConfig,
75
73
  serverConfig,
76
74
  worker: workerData?.worker,
75
+ resourceLimits: workerData?.resourceLimits,
77
76
  hasManagementApi: !!runtimeConfig.managementApi,
78
77
  fetchApplicationUrl: fetchApplicationUrl.bind(null, applicationConfig)
79
78
  }
@@ -261,13 +260,10 @@ export class Controller extends EventEmitter {
261
260
 
262
261
  async getHealth () {
263
262
  const currentELU = performance.eventLoopUtilization()
264
- const elu = performance.eventLoopUtilization(currentELU, this.#lastELU).utilization
265
- this.#lastELU = currentELU
266
-
267
263
  const { heapUsed, heapTotal } = process.memoryUsage()
268
264
 
269
265
  return {
270
- elu,
266
+ currentELU,
271
267
  heapUsed,
272
268
  heapTotal
273
269
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/runtime",
3
- "version": "3.51.0",
3
+ "version": "3.52.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -36,14 +36,14 @@
36
36
  "typescript": "^5.5.4",
37
37
  "undici-oidc-interceptor": "^0.5.0",
38
38
  "why-is-node-running": "^2.2.2",
39
- "@platformatic/composer": "3.51.0",
40
- "@platformatic/db": "3.51.0",
41
- "@platformatic/node": "3.51.0",
42
- "@platformatic/service": "3.51.0",
43
- "@platformatic/sql-graphql": "3.51.0",
44
- "@platformatic/gateway": "3.51.0",
45
- "@platformatic/sql-mapper": "3.51.0",
46
- "@platformatic/wattpm-pprof-capture": "3.51.0"
39
+ "@platformatic/composer": "3.52.1",
40
+ "@platformatic/db": "3.52.1",
41
+ "@platformatic/gateway": "3.52.1",
42
+ "@platformatic/service": "3.52.1",
43
+ "@platformatic/node": "3.52.1",
44
+ "@platformatic/sql-graphql": "3.52.1",
45
+ "@platformatic/sql-mapper": "3.52.1",
46
+ "@platformatic/wattpm-pprof-capture": "3.52.1"
47
47
  },
48
48
  "dependencies": {
49
49
  "@fastify/accepts": "^5.0.0",
@@ -73,12 +73,12 @@
73
73
  "undici": "^7.0.0",
74
74
  "undici-thread-interceptor": "^1.3.1",
75
75
  "ws": "^8.16.0",
76
- "@platformatic/basic": "3.51.0",
77
- "@platformatic/generators": "3.51.0",
78
- "@platformatic/foundation": "3.51.0",
79
- "@platformatic/metrics": "3.51.0",
80
- "@platformatic/itc": "3.51.0",
81
- "@platformatic/telemetry": "3.51.0"
76
+ "@platformatic/foundation": "3.52.1",
77
+ "@platformatic/basic": "3.52.1",
78
+ "@platformatic/generators": "3.52.1",
79
+ "@platformatic/metrics": "3.52.1",
80
+ "@platformatic/telemetry": "3.52.1",
81
+ "@platformatic/itc": "3.52.1"
82
82
  },
83
83
  "engines": {
84
84
  "node": ">=22.19.0"
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/runtime/3.51.0.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/runtime/3.52.1.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Runtime Config",
5
5
  "type": "object",
@@ -1702,8 +1702,7 @@
1702
1702
  "type": "object",
1703
1703
  "properties": {
1704
1704
  "hostname": {
1705
- "type": "string",
1706
- "default": "127.0.0.1"
1705
+ "type": "string"
1707
1706
  },
1708
1707
  "port": {
1709
1708
  "anyOf": [