@platformatic/service 0.30.1 → 0.31.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/compile.js +2 -2
- package/lib/plugins/metrics.js +4 -8
- package/package.json +6 -6
- package/test/cli/compile-1.test.mjs +4 -4
- package/test/metrics.test.js +23 -0
package/lib/compile.js
CHANGED
|
@@ -55,8 +55,8 @@ async function setup (cwd, config, logger) {
|
|
|
55
55
|
const tsConfigExists = await isFileAccessible(tsConfigPath)
|
|
56
56
|
|
|
57
57
|
if (!tsConfigExists) {
|
|
58
|
-
const msg = 'No typescript configuration file was found.'
|
|
59
|
-
logger.
|
|
58
|
+
const msg = 'No typescript configuration file was found, skipping compilation.'
|
|
59
|
+
logger.info(msg)
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
return { execa, logger, tscExecutablePath, tsConfigPath, tsConfigExists }
|
package/lib/plugins/metrics.js
CHANGED
|
@@ -12,7 +12,6 @@ const Fastify = require('fastify')
|
|
|
12
12
|
// prometheus. It's an antipattern, so do
|
|
13
13
|
// not use it elsewhere.
|
|
14
14
|
let server = null
|
|
15
|
-
let handler = null
|
|
16
15
|
|
|
17
16
|
module.exports = fp(async function (app, opts) {
|
|
18
17
|
let port = 9090
|
|
@@ -60,7 +59,6 @@ module.exports = fp(async function (app, opts) {
|
|
|
60
59
|
if (server && server.address().port !== port) {
|
|
61
60
|
await new Promise((resolve) => server.close(resolve))
|
|
62
61
|
server = null
|
|
63
|
-
handler = null
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
if (!server) {
|
|
@@ -71,12 +69,10 @@ module.exports = fp(async function (app, opts) {
|
|
|
71
69
|
|
|
72
70
|
const promServer = Fastify({
|
|
73
71
|
name: 'Prometheus server',
|
|
74
|
-
serverFactory: (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
server.on('request', _handler)
|
|
79
|
-
handler = _handler
|
|
72
|
+
serverFactory: (handler) => {
|
|
73
|
+
server.removeAllListeners('request')
|
|
74
|
+
server.removeAllListeners('clientError')
|
|
75
|
+
server.on('request', handler)
|
|
80
76
|
return server
|
|
81
77
|
},
|
|
82
78
|
logger: app.log.child({ name: 'prometheus' })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/service",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -64,11 +64,11 @@
|
|
|
64
64
|
"pino-pretty": "^10.0.0",
|
|
65
65
|
"rfdc": "^1.3.0",
|
|
66
66
|
"ua-parser-js": "^1.0.35",
|
|
67
|
-
"@platformatic/client": "0.
|
|
68
|
-
"@platformatic/config": "0.
|
|
69
|
-
"@platformatic/swagger-ui-theme": "0.
|
|
70
|
-
"@platformatic/types": "0.
|
|
71
|
-
"@platformatic/utils": "0.
|
|
67
|
+
"@platformatic/client": "0.31.1",
|
|
68
|
+
"@platformatic/config": "0.31.1",
|
|
69
|
+
"@platformatic/swagger-ui-theme": "0.31.1",
|
|
70
|
+
"@platformatic/types": "0.31.1",
|
|
71
|
+
"@platformatic/utils": "0.31.1"
|
|
72
72
|
},
|
|
73
73
|
"standard": {
|
|
74
74
|
"ignore": [
|
|
@@ -162,7 +162,7 @@ t.test('missing tsconfig file', async (t) => {
|
|
|
162
162
|
} catch (err) {
|
|
163
163
|
t.comment(err.stdout)
|
|
164
164
|
t.comment(err.stderr)
|
|
165
|
-
t.equal(err.stdout.includes('No typescript configuration file was found.'), true)
|
|
165
|
+
t.equal(err.stdout.includes('No typescript configuration file was found, skipping compilation.'), true)
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
t.pass()
|
|
@@ -217,7 +217,7 @@ t.test('should not compile typescript plugin with start without tsconfig', async
|
|
|
217
217
|
t.fail('should not compile typescript plugin with start without tsconfig')
|
|
218
218
|
} catch (err) {
|
|
219
219
|
t.comment(err.stdout)
|
|
220
|
-
t.equal(err.stdout.includes('No typescript configuration file was found'), true)
|
|
220
|
+
t.equal(err.stdout.includes('No typescript configuration file was found, skipping compilation.'), true)
|
|
221
221
|
}
|
|
222
222
|
})
|
|
223
223
|
|
|
@@ -441,7 +441,7 @@ t.test('missing tsconfig file', async (t) => {
|
|
|
441
441
|
} catch (err) {
|
|
442
442
|
t.comment(err.stdout)
|
|
443
443
|
t.comment(err.stderr)
|
|
444
|
-
t.equal(err.stdout.includes('No typescript configuration file was found.'), true)
|
|
444
|
+
t.equal(err.stdout.includes('No typescript configuration file was found, skipping compilation.'), true)
|
|
445
445
|
}
|
|
446
446
|
|
|
447
447
|
t.pass()
|
|
@@ -495,6 +495,6 @@ t.test('should not compile typescript plugin with start without tsconfig', async
|
|
|
495
495
|
t.fail('should not compile typescript plugin with start without tsconfig')
|
|
496
496
|
} catch (err) {
|
|
497
497
|
t.comment(err.stdout)
|
|
498
|
-
t.equal(err.stdout.includes('No typescript configuration file was found.'), true)
|
|
498
|
+
t.equal(err.stdout.includes('No typescript configuration file was found, skipping compilation.'), true)
|
|
499
499
|
}
|
|
500
500
|
})
|
package/test/metrics.test.js
CHANGED
|
@@ -154,6 +154,29 @@ test('do not error on restart', async ({ teardown, equal, fail, match }) => {
|
|
|
154
154
|
testPrometheusOutput(body)
|
|
155
155
|
})
|
|
156
156
|
|
|
157
|
+
test('restarting 10 times does not leak', async ({ teardown, equal, fail, match }) => {
|
|
158
|
+
process.on('warning', (warning) => {
|
|
159
|
+
fail('warning was raised')
|
|
160
|
+
})
|
|
161
|
+
const app = await buildServer({
|
|
162
|
+
server: {
|
|
163
|
+
hostname: '127.0.0.1',
|
|
164
|
+
port: 0
|
|
165
|
+
},
|
|
166
|
+
metrics: true
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
teardown(async () => {
|
|
170
|
+
await app.close()
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
await app.start()
|
|
174
|
+
|
|
175
|
+
for (let i = 0; i < 10; i++) {
|
|
176
|
+
await app.restart()
|
|
177
|
+
}
|
|
178
|
+
})
|
|
179
|
+
|
|
157
180
|
function testPrometheusOutput (output) {
|
|
158
181
|
let metricBlock = []
|
|
159
182
|
const lines = output.split('\n')
|