@platformatic/runtime 0.31.0 → 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.
@@ -0,0 +1,4 @@
1
+ CREATE TABLE IF NOT EXISTS movies (
2
+ id INTEGER PRIMARY KEY,
3
+ title TEXT NOT NULL fiddlesticks
4
+ );
@@ -0,0 +1 @@
1
+ DROP TABLE movies;
@@ -0,0 +1,28 @@
1
+ {
2
+ "$schema": "https://platformatic.dev/schemas/v0.30.0/db",
3
+ "server": {
4
+ "hostname": "127.0.0.1",
5
+ "port": 3042
6
+ },
7
+ "migrations": {
8
+ "autoApply": true,
9
+ "dir": "migrations",
10
+ "table": "versions"
11
+ },
12
+ "types": {
13
+ "autogenerate": false
14
+ },
15
+ "plugins": {
16
+ "paths": [
17
+ "plugin.js"
18
+ ]
19
+ },
20
+ "db": {
21
+ "connectionString": "sqlite://db.sqlite",
22
+ "graphql": true,
23
+ "ignore": {
24
+ "versions": true
25
+ },
26
+ "events": false
27
+ }
28
+ }
@@ -0,0 +1,5 @@
1
+ /// <reference path="./global.d.ts" />
2
+ 'use strict'
3
+
4
+ /** @param {import('fastify').FastifyInstance} app */
5
+ module.exports = async function (app) {}
@@ -11,6 +11,14 @@ class MessagePortWritable extends Writable {
11
11
  this.metadata = opts.metadata
12
12
  }
13
13
 
14
+ _write (chunk, encoding, callback) {
15
+ this.port.postMessage({
16
+ metadata: this.metadata,
17
+ logs: [chunk.toString().trim()]
18
+ })
19
+ process.nextTick(callback)
20
+ }
21
+
14
22
  _writev (chunks, callback) {
15
23
  // Process the logs here before trying to send them across the thread
16
24
  // boundary. Sometimes the chunks have an undocumented method on them
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/runtime",
3
- "version": "0.31.0",
3
+ "version": "0.31.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -24,8 +24,8 @@
24
24
  "standard": "^17.1.0",
25
25
  "tsd": "^0.28.1",
26
26
  "typescript": "^5.1.6",
27
- "@platformatic/sql-mapper": "0.31.0",
28
- "@platformatic/sql-graphql": "0.31.0"
27
+ "@platformatic/sql-mapper": "0.31.1",
28
+ "@platformatic/sql-graphql": "0.31.1"
29
29
  },
30
30
  "dependencies": {
31
31
  "@hapi/topo": "^6.0.2",
@@ -40,11 +40,11 @@
40
40
  "pino": "^8.14.1",
41
41
  "pino-pretty": "^10.0.0",
42
42
  "undici": "^5.22.1",
43
- "@platformatic/composer": "0.31.0",
44
- "@platformatic/config": "0.31.0",
45
- "@platformatic/db": "0.31.0",
46
- "@platformatic/service": "0.31.0",
47
- "@platformatic/utils": "0.31.0"
43
+ "@platformatic/composer": "0.31.1",
44
+ "@platformatic/config": "0.31.1",
45
+ "@platformatic/db": "0.31.1",
46
+ "@platformatic/service": "0.31.1",
47
+ "@platformatic/utils": "0.31.1"
48
48
  },
49
49
  "standard": {
50
50
  "ignore": [
@@ -8,6 +8,7 @@ const { MessageChannel } = require('node:worker_threads')
8
8
  const { request } = require('undici')
9
9
  const { loadConfig } = require('@platformatic/service')
10
10
  const { buildServer, platformaticRuntime } = require('..')
11
+ const { wrapConfigInRuntimeConfig } = require('../lib/config')
11
12
  const { startWithConfig } = require('../lib/start')
12
13
  const fixturesDir = join(__dirname, '..', 'fixtures')
13
14
 
@@ -156,3 +157,30 @@ test('handles uncaught exceptions with db app', async (t) => {
156
157
 
157
158
  assert.strictEqual(exitCode, 42)
158
159
  })
160
+
161
+ test('logs errors during db migrations', async (t) => {
162
+ const configFile = join(fixturesDir, 'dbAppWithMigrationError', 'platformatic.db.json')
163
+ const config = await loadConfig({}, ['-c', configFile], 'db')
164
+ const runtimeConfig = await wrapConfigInRuntimeConfig(config)
165
+ const { port1, port2 } = new MessageChannel()
166
+ runtimeConfig.current.loggingPort = port2
167
+ runtimeConfig.current.loggingMetadata = { foo: 1, bar: 2 }
168
+ const runtime = await startWithConfig(runtimeConfig)
169
+ const messages = []
170
+
171
+ port1.on('message', (msg) => {
172
+ messages.push(msg)
173
+ })
174
+
175
+ await assert.rejects(async () => {
176
+ await runtime.start()
177
+ }, /The runtime exited before the operation completed/)
178
+
179
+ assert.strictEqual(messages.length, 2)
180
+ assert.deepStrictEqual(messages[0].metadata, runtimeConfig.current.loggingMetadata)
181
+ assert.strictEqual(messages[0].logs.length, 1)
182
+ assert.match(messages[0].logs[0], /running 001.do.sql/)
183
+ assert.deepStrictEqual(messages[1].metadata, runtimeConfig.current.loggingMetadata)
184
+ assert.strictEqual(messages[1].logs.length, 1)
185
+ assert.match(messages[1].logs[0], /near \\"fiddlesticks\\": syntax error/)
186
+ })