@platformatic/runtime 1.52.2 → 1.53.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/lib/api-client.js +14 -12
- package/package.json +29 -28
package/lib/api-client.js
CHANGED
|
@@ -8,6 +8,7 @@ const { createReadStream, watch } = require('node:fs')
|
|
|
8
8
|
const { readdir, readFile, stat, access } = require('node:fs/promises')
|
|
9
9
|
const { setTimeout: sleep } = require('node:timers/promises')
|
|
10
10
|
const errors = require('./errors')
|
|
11
|
+
const { Unpromise } = require('@watchable/unpromise')
|
|
11
12
|
const ts = require('tail-file-stream')
|
|
12
13
|
|
|
13
14
|
const platformaticVersion = require('../package.json').version
|
|
@@ -99,7 +100,7 @@ class RuntimeApiClient extends EventEmitter {
|
|
|
99
100
|
await this.#sendCommand('plt:stop-services')
|
|
100
101
|
|
|
101
102
|
this.worker.postMessage({ command: 'plt:close' })
|
|
102
|
-
const res = await
|
|
103
|
+
const res = await Unpromise.race([
|
|
103
104
|
this.#exitPromise,
|
|
104
105
|
// We must kill the worker if it doesn't exit in 10 seconds
|
|
105
106
|
// because it may be stuck in an infinite loop.
|
|
@@ -286,10 +287,11 @@ class RuntimeApiClient extends EventEmitter {
|
|
|
286
287
|
|
|
287
288
|
let latestFileId = parseInt(runtimeLogFiles.at(-1).slice('logs.'.length))
|
|
288
289
|
|
|
289
|
-
let waiting = false
|
|
290
290
|
let fileStream = null
|
|
291
291
|
let fileId = startLogId ?? latestFileId
|
|
292
292
|
|
|
293
|
+
let isClosed = false
|
|
294
|
+
|
|
293
295
|
const runtimeLogsDir = this.#getRuntimeLogsDir(runtimePID)
|
|
294
296
|
|
|
295
297
|
const watcher = watch(runtimeLogsDir, async (event, filename) => {
|
|
@@ -297,9 +299,7 @@ class RuntimeApiClient extends EventEmitter {
|
|
|
297
299
|
const logFileId = parseInt(filename.slice('logs.'.length))
|
|
298
300
|
if (logFileId > latestFileId) {
|
|
299
301
|
latestFileId = logFileId
|
|
300
|
-
|
|
301
|
-
streamLogFile(++fileId)
|
|
302
|
-
}
|
|
302
|
+
fileStream.unwatch()
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
}).unref()
|
|
@@ -324,25 +324,25 @@ class RuntimeApiClient extends EventEmitter {
|
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
fileStream.on('error', (err) => {
|
|
327
|
+
isClosed = true
|
|
327
328
|
logger.error(err, 'Error streaming log file')
|
|
328
329
|
fileStream.destroy()
|
|
329
330
|
watcher.close()
|
|
330
331
|
writableStream.end()
|
|
331
332
|
})
|
|
332
333
|
|
|
333
|
-
fileStream.on('
|
|
334
|
-
|
|
334
|
+
fileStream.on('close', () => {
|
|
335
|
+
if (latestFileId > fileId && !isClosed) {
|
|
336
|
+
streamLogFile(++fileId)
|
|
337
|
+
}
|
|
335
338
|
})
|
|
336
339
|
|
|
337
340
|
fileStream.on('eof', () => {
|
|
338
341
|
if (fileId >= endLogId) {
|
|
339
342
|
writableStream.end()
|
|
340
|
-
return
|
|
341
343
|
}
|
|
342
344
|
if (latestFileId > fileId) {
|
|
343
|
-
|
|
344
|
-
} else {
|
|
345
|
-
waiting = true
|
|
345
|
+
fileStream.unwatch()
|
|
346
346
|
}
|
|
347
347
|
})
|
|
348
348
|
|
|
@@ -352,10 +352,12 @@ class RuntimeApiClient extends EventEmitter {
|
|
|
352
352
|
streamLogFile(fileId)
|
|
353
353
|
|
|
354
354
|
writableStream.on('close', () => {
|
|
355
|
+
isClosed = true
|
|
355
356
|
watcher.close()
|
|
356
357
|
fileStream.destroy()
|
|
357
358
|
})
|
|
358
359
|
writableStream.on('error', () => {
|
|
360
|
+
isClosed = true
|
|
359
361
|
watcher.close()
|
|
360
362
|
fileStream.destroy()
|
|
361
363
|
})
|
|
@@ -446,7 +448,7 @@ class RuntimeApiClient extends EventEmitter {
|
|
|
446
448
|
async #sendCommand (command, params = {}) {
|
|
447
449
|
const operationId = randomUUID()
|
|
448
450
|
this.worker.postMessage({ operationId, command, params })
|
|
449
|
-
const [message] = await
|
|
451
|
+
const [message] = await Unpromise.race(
|
|
450
452
|
[once(this, operationId), this.#exitPromise]
|
|
451
453
|
)
|
|
452
454
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/runtime",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.53.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -21,56 +21,57 @@
|
|
|
21
21
|
"@fastify/formbody": "^7.4.0",
|
|
22
22
|
"@matteo.collina/tspl": "^0.1.1",
|
|
23
23
|
"borp": "^0.16.0",
|
|
24
|
-
"c8": "^10.
|
|
24
|
+
"c8": "^10.1.2",
|
|
25
25
|
"execa": "^8.0.1",
|
|
26
|
-
"express": "^4.
|
|
27
|
-
"fast-jwt": "^4.0.
|
|
26
|
+
"express": "^4.20.0",
|
|
27
|
+
"fast-jwt": "^4.0.5",
|
|
28
28
|
"get-port": "^7.1.0",
|
|
29
|
-
"pino-abstract-transport": "^1.
|
|
29
|
+
"pino-abstract-transport": "^1.2.0",
|
|
30
30
|
"snazzy": "^9.0.0",
|
|
31
31
|
"split2": "^4.2.0",
|
|
32
32
|
"standard": "^17.1.0",
|
|
33
|
-
"tsd": "^0.31.
|
|
34
|
-
"typescript": "^5.
|
|
33
|
+
"tsd": "^0.31.2",
|
|
34
|
+
"typescript": "^5.6.2",
|
|
35
35
|
"undici-oidc-interceptor": "^0.5.0",
|
|
36
36
|
"why-is-node-running": "^2.2.2",
|
|
37
|
-
"@platformatic/sql-graphql": "1.
|
|
38
|
-
"@platformatic/sql-mapper": "1.
|
|
37
|
+
"@platformatic/sql-graphql": "1.53.0",
|
|
38
|
+
"@platformatic/sql-mapper": "1.53.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@fastify/error": "^3.4.1",
|
|
42
|
-
"@fastify/websocket": "^10.0.
|
|
42
|
+
"@fastify/websocket": "^10.0.1",
|
|
43
43
|
"@hapi/topo": "^6.0.2",
|
|
44
|
+
"@watchable/unpromise": "^1.0.2",
|
|
44
45
|
"boring-name-generator": "^1.0.3",
|
|
45
46
|
"change-case-all": "^2.1.0",
|
|
46
47
|
"close-with-grace": "^1.3.0",
|
|
47
48
|
"commist": "^3.2.0",
|
|
48
|
-
"debounce": "^2.
|
|
49
|
+
"debounce": "^2.1.1",
|
|
49
50
|
"desm": "^1.3.1",
|
|
50
51
|
"dotenv-tool": "^0.1.1",
|
|
51
52
|
"es-main": "^1.3.0",
|
|
52
53
|
"fastest-levenshtein": "^1.0.16",
|
|
53
|
-
"fastify": "^4.
|
|
54
|
+
"fastify": "^4.28.1",
|
|
54
55
|
"fastify-undici-dispatcher": "^0.6.0",
|
|
55
|
-
"graphql": "^16.
|
|
56
|
+
"graphql": "^16.9.0",
|
|
56
57
|
"help-me": "^5.0.0",
|
|
57
58
|
"minimist": "^1.2.8",
|
|
58
|
-
"pino": "^8.
|
|
59
|
-
"pino-pretty": "^11.
|
|
60
|
-
"pino-roll": "^1.
|
|
59
|
+
"pino": "^8.21.0",
|
|
60
|
+
"pino-pretty": "^11.2.2",
|
|
61
|
+
"pino-roll": "^1.3.0",
|
|
61
62
|
"semgrator": "^0.3.0",
|
|
62
|
-
"tail-file-stream": "^0.
|
|
63
|
-
"undici": "^6.
|
|
64
|
-
"why-is-node-running": "^2.
|
|
65
|
-
"ws": "^8.
|
|
66
|
-
"@platformatic/
|
|
67
|
-
"@platformatic/
|
|
68
|
-
"@platformatic/
|
|
69
|
-
"@platformatic/
|
|
70
|
-
"@platformatic/service": "1.
|
|
71
|
-
"@platformatic/
|
|
72
|
-
"@platformatic/
|
|
73
|
-
"@platformatic/utils": "1.
|
|
63
|
+
"tail-file-stream": "^0.2.0",
|
|
64
|
+
"undici": "^6.19.8",
|
|
65
|
+
"why-is-node-running": "^2.3.0",
|
|
66
|
+
"ws": "^8.18.0",
|
|
67
|
+
"@platformatic/bus": "1.53.0",
|
|
68
|
+
"@platformatic/composer": "1.53.0",
|
|
69
|
+
"@platformatic/config": "1.53.0",
|
|
70
|
+
"@platformatic/db": "1.53.0",
|
|
71
|
+
"@platformatic/service": "1.53.0",
|
|
72
|
+
"@platformatic/generators": "1.53.0",
|
|
73
|
+
"@platformatic/telemetry": "1.53.0",
|
|
74
|
+
"@platformatic/utils": "1.53.0"
|
|
74
75
|
},
|
|
75
76
|
"standard": {
|
|
76
77
|
"ignore": [
|