@platformatic/runtime 2.66.0 → 2.66.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/config.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * and run json-schema-to-typescript to regenerate this file.
6
6
  */
7
7
 
8
- export type HttpsSchemasPlatformaticDevPlatformaticRuntime2660Json = {
8
+ export type HttpsSchemasPlatformaticDevPlatformaticRuntime2661Json = {
9
9
  [k: string]: unknown;
10
10
  } & {
11
11
  $schema?: string;
package/lib/config.js CHANGED
@@ -263,10 +263,15 @@ async function wrapConfigInRuntimeConfig ({ configManager, args }) {
263
263
  // on purpose, the package.json might be missing
264
264
  }
265
265
 
266
+ // If the service supports its (so far, only @platformatic/service and descendants)
267
+ const { hostname, port, http2, https } = configManager.current.server ?? {}
268
+ const server = { hostname, port, http2, https }
269
+
266
270
  // Important: do not change the order of the properties in this object
267
271
  /* c8 ignore next */
268
272
  const wrapperConfig = {
269
273
  $schema: schema.$id,
274
+ server,
270
275
  watch: true,
271
276
  ...omitProperties(configManager.current.runtime ?? {}, runtimeUnwrappablePropertiesList),
272
277
  entrypoint: serviceId,
package/lib/start.js CHANGED
@@ -91,16 +91,29 @@ async function setupAndStartRuntime (config) {
91
91
 
92
92
  let address = null
93
93
  const startErr = null
94
- const originalPort = runtimeConfig.current.server?.port || 0
94
+
95
+ runtimeConfig.current.server ??= { port: 0 }
96
+ let port = runtimeConfig.current.server.port
95
97
  while (address === null) {
96
98
  try {
97
99
  address = await runtime.start()
98
100
  } catch (err) {
99
101
  if (err.code === 'EADDRINUSE') {
102
+ // Get the actual port from the error message if original port was 0
103
+ if (!port) {
104
+ const mo = err.message.match(/ address already in use (.+)/)
105
+ const url = new URL(`http://${mo[1]}`)
106
+ port = Number(url.port)
107
+ }
108
+
109
+ port++
100
110
  await runtime.close()
101
111
 
102
- if (runtimeConfig.current?.server?.port > MAX_PORT) throw err
103
- runtimeConfig.current.server.port++
112
+ if (port > MAX_PORT) {
113
+ throw err
114
+ }
115
+
116
+ runtimeConfig.current.server.port = port
104
117
  runtime = await buildRuntime(runtimeConfig)
105
118
  } else {
106
119
  throw err
@@ -114,7 +127,7 @@ async function setupAndStartRuntime (config) {
114
127
  ignore: 'hostname,pid'
115
128
  })
116
129
  )
117
- logger.warn(`Port: ${originalPort} is already in use!`)
130
+ logger.warn(`Port: ${port} is already in use!`)
118
131
  logger.warn(`Changing the port to ${runtimeConfig.current.server.port}`)
119
132
  }
120
133
  return { address, runtime }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/runtime",
3
- "version": "2.66.0",
3
+ "version": "2.66.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -37,12 +37,12 @@
37
37
  "typescript": "^5.5.4",
38
38
  "undici-oidc-interceptor": "^0.5.0",
39
39
  "why-is-node-running": "^2.2.2",
40
- "@platformatic/composer": "2.66.0",
41
- "@platformatic/db": "2.66.0",
42
- "@platformatic/node": "2.66.0",
43
- "@platformatic/service": "2.66.0",
44
- "@platformatic/sql-mapper": "2.66.0",
45
- "@platformatic/sql-graphql": "2.66.0"
40
+ "@platformatic/composer": "2.66.1",
41
+ "@platformatic/db": "2.66.1",
42
+ "@platformatic/node": "2.66.1",
43
+ "@platformatic/service": "2.66.1",
44
+ "@platformatic/sql-graphql": "2.66.1",
45
+ "@platformatic/sql-mapper": "2.66.1"
46
46
  },
47
47
  "dependencies": {
48
48
  "@fastify/accepts": "^5.0.0",
@@ -77,13 +77,13 @@
77
77
  "undici": "^7.0.0",
78
78
  "undici-thread-interceptor": "^0.13.1",
79
79
  "ws": "^8.16.0",
80
- "@platformatic/basic": "2.66.0",
81
- "@platformatic/generators": "2.66.0",
82
- "@platformatic/config": "2.66.0",
83
- "@platformatic/itc": "2.66.0",
84
- "@platformatic/ts-compiler": "2.66.0",
85
- "@platformatic/telemetry": "2.66.0",
86
- "@platformatic/utils": "2.66.0"
80
+ "@platformatic/basic": "2.66.1",
81
+ "@platformatic/config": "2.66.1",
82
+ "@platformatic/itc": "2.66.1",
83
+ "@platformatic/telemetry": "2.66.1",
84
+ "@platformatic/generators": "2.66.1",
85
+ "@platformatic/ts-compiler": "2.66.1",
86
+ "@platformatic/utils": "2.66.1"
87
87
  },
88
88
  "scripts": {
89
89
  "test": "pnpm run lint && borp --concurrency=1 --timeout=300000 && tsd",
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/runtime/2.66.0.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/runtime/2.66.1.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "type": "object",
5
5
  "properties": {