@platformatic/runtime 2.52.0 → 2.52.1-alpha.0
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 +1 -1
- package/lib/runtime.js +35 -23
- package/package.json +14 -14
- package/schema.json +1 -1
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
|
|
8
|
+
export type HttpsSchemasPlatformaticDevPlatformaticRuntime2521Alpha0Json = {
|
|
9
9
|
[k: string]: unknown;
|
|
10
10
|
} & {
|
|
11
11
|
$schema?: string;
|
package/lib/runtime.js
CHANGED
|
@@ -6,11 +6,9 @@ const { once, EventEmitter } = require('node:events')
|
|
|
6
6
|
const { createReadStream, watch, existsSync } = require('node:fs')
|
|
7
7
|
const { readdir, readFile, stat, access } = require('node:fs/promises')
|
|
8
8
|
const { STATUS_CODES } = require('node:http')
|
|
9
|
-
const { hostname } = require('node:os')
|
|
10
9
|
const { join } = require('node:path')
|
|
11
10
|
const { setTimeout: sleep, setImmediate: sleepUntilNextTick } = require('node:timers/promises')
|
|
12
11
|
const { Worker } = require('node:worker_threads')
|
|
13
|
-
const split2 = require('split2')
|
|
14
12
|
const ts = require('tail-file-stream')
|
|
15
13
|
const { Agent, interceptors: undiciInterceptors, request } = require('undici')
|
|
16
14
|
const { createThreadInterceptor } = require('undici-thread-interceptor')
|
|
@@ -1675,20 +1673,21 @@ class Runtime extends EventEmitter {
|
|
|
1675
1673
|
}
|
|
1676
1674
|
|
|
1677
1675
|
#handleWorkerStandardStreams (worker, serviceId, workerId) {
|
|
1678
|
-
const
|
|
1676
|
+
const binding = { name: serviceId }
|
|
1679
1677
|
|
|
1680
1678
|
if (typeof workerId !== 'undefined') {
|
|
1681
|
-
|
|
1679
|
+
binding.worker = workerId
|
|
1682
1680
|
}
|
|
1683
1681
|
|
|
1684
|
-
const logger = this.logger.child(
|
|
1682
|
+
const logger = this.logger.child(binding, { level: 'trace' })
|
|
1685
1683
|
|
|
1686
1684
|
const selectors = {
|
|
1687
1685
|
stdout: { level: 'info', caller: 'STDOUT' },
|
|
1688
1686
|
stderr: { level: 'error', caller: 'STDERR' }
|
|
1689
1687
|
}
|
|
1690
1688
|
|
|
1691
|
-
worker.stdout.
|
|
1689
|
+
worker.stdout.setEncoding('utf8')
|
|
1690
|
+
worker.stdout.on('data', raw => {
|
|
1692
1691
|
let selector = selectors.stdout
|
|
1693
1692
|
|
|
1694
1693
|
if (raw.includes(kStderrMarker)) {
|
|
@@ -1701,39 +1700,52 @@ class Runtime extends EventEmitter {
|
|
|
1701
1700
|
|
|
1702
1701
|
// Whatever is outputted here, it come from a direct process.stderr.write in the thread.
|
|
1703
1702
|
// There's nothing we can do about it in regard of out of order logs due to a Node bug.
|
|
1704
|
-
worker.stderr.
|
|
1703
|
+
worker.stderr.setEncoding('utf8')
|
|
1704
|
+
worker.stderr.on('data', raw => {
|
|
1705
1705
|
this.#forwardThreadLog(logger, selectors.stderr, raw)
|
|
1706
1706
|
})
|
|
1707
1707
|
}
|
|
1708
1708
|
|
|
1709
|
-
#forwardThreadLog (logger, { level, caller },
|
|
1709
|
+
#forwardThreadLog (logger, { level, caller }, data) {
|
|
1710
1710
|
if (!this.#loggerDestination) {
|
|
1711
1711
|
return
|
|
1712
1712
|
}
|
|
1713
1713
|
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
message
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1714
|
+
let plainMessages = ''
|
|
1715
|
+
for (const raw of data.split('\n')) {
|
|
1716
|
+
// First of all, try to parse the message as JSON
|
|
1717
|
+
let message
|
|
1718
|
+
try {
|
|
1719
|
+
message = JSON.parse(raw)
|
|
1720
|
+
} catch (e) {
|
|
1721
|
+
// No-op, we assume the message is raw
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
// Not a Pino JSON, accumulate the message and continue
|
|
1725
|
+
if (typeof message?.level !== 'number' || typeof message?.time !== 'number') {
|
|
1726
|
+
plainMessages += (plainMessages.length ? '\n' : '') + raw
|
|
1727
|
+
continue
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
// Before continuing, write any previous plain messages
|
|
1731
|
+
if (plainMessages.length > 0) {
|
|
1732
|
+
logger[level]({ caller }, plainMessages.replace(/\n$/, ''))
|
|
1733
|
+
plainMessages = ''
|
|
1734
|
+
}
|
|
1721
1735
|
|
|
1722
|
-
|
|
1723
|
-
if (!message) {
|
|
1724
|
-
// Log the message
|
|
1725
|
-
logger[level]({ caller }, raw.replace(/\n$/, ''))
|
|
1726
|
-
} else if (typeof message?.level === 'number' && typeof message?.time === 'number') {
|
|
1736
|
+
// Now we directly write to the Pino destination
|
|
1727
1737
|
this.#loggerDestination.lastLevel = message.level
|
|
1728
1738
|
this.#loggerDestination.lastTime = message.time
|
|
1729
1739
|
this.#loggerDestination.lastMsg = message.msg
|
|
1730
1740
|
this.#loggerDestination.lastObj = message
|
|
1731
1741
|
this.#loggerDestination.lastLogger = logger
|
|
1732
1742
|
|
|
1733
|
-
// Remember to add '\n' back as split2 removed it
|
|
1734
1743
|
this.#loggerDestination.write(raw + '\n')
|
|
1735
|
-
}
|
|
1736
|
-
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
// Write whatever is left
|
|
1747
|
+
if (plainMessages.length > 0) {
|
|
1748
|
+
logger[level]({ caller }, plainMessages.replace(/\n$/, ''))
|
|
1737
1749
|
}
|
|
1738
1750
|
}
|
|
1739
1751
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/runtime",
|
|
3
|
-
"version": "2.52.0",
|
|
3
|
+
"version": "2.52.1-alpha.0",
|
|
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.52.0",
|
|
41
|
-
"@platformatic/
|
|
42
|
-
"@platformatic/
|
|
43
|
-
"@platformatic/
|
|
44
|
-
"@platformatic/sql-
|
|
45
|
-
"@platformatic/
|
|
40
|
+
"@platformatic/composer": "2.52.1-alpha.0",
|
|
41
|
+
"@platformatic/node": "2.52.1-alpha.0",
|
|
42
|
+
"@platformatic/service": "2.52.1-alpha.0",
|
|
43
|
+
"@platformatic/sql-graphql": "2.52.1-alpha.0",
|
|
44
|
+
"@platformatic/sql-mapper": "2.52.1-alpha.0",
|
|
45
|
+
"@platformatic/db": "2.52.1-alpha.0"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@fastify/accepts": "^5.0.0",
|
|
@@ -76,13 +76,13 @@
|
|
|
76
76
|
"undici": "^7.0.0",
|
|
77
77
|
"undici-thread-interceptor": "^0.13.1",
|
|
78
78
|
"ws": "^8.16.0",
|
|
79
|
-
"@platformatic/basic": "2.52.0",
|
|
80
|
-
"@platformatic/config": "2.52.0",
|
|
81
|
-
"@platformatic/generators": "2.52.0",
|
|
82
|
-
"@platformatic/itc": "2.52.0",
|
|
83
|
-
"@platformatic/telemetry": "2.52.0",
|
|
84
|
-
"@platformatic/
|
|
85
|
-
"@platformatic/
|
|
79
|
+
"@platformatic/basic": "2.52.1-alpha.0",
|
|
80
|
+
"@platformatic/config": "2.52.1-alpha.0",
|
|
81
|
+
"@platformatic/generators": "2.52.1-alpha.0",
|
|
82
|
+
"@platformatic/itc": "2.52.1-alpha.0",
|
|
83
|
+
"@platformatic/telemetry": "2.52.1-alpha.0",
|
|
84
|
+
"@platformatic/ts-compiler": "2.52.1-alpha.0",
|
|
85
|
+
"@platformatic/utils": "2.52.1-alpha.0"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
88
|
"test": "npm run lint && borp --concurrency=1 --timeout=300000 && tsd",
|
package/schema.json
CHANGED