Skip to content

Commit 6c2355f

Browse files
authored
fix: return reply on healthcheck (#833)
1 parent 0a39687 commit 6c2355f

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

src/http/routes/admin/tenants.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ export default async function routes(fastify: FastifyInstance) {
578578
tenantId,
579579
upToMigration: dbMigrationFreezeAt,
580580
})
581-
reply.send({
581+
return reply.send({
582582
migrated: true,
583583
})
584584
} catch (e) {
@@ -668,12 +668,12 @@ export default async function routes(fastify: FastifyInstance) {
668668
fastify.get<tenantRequestInterface>('/:tenantId/health', async (req, res) => {
669669
try {
670670
await req.storage.healthcheck()
671-
res.send({ healthy: true })
671+
return res.send({ healthy: true })
672672
} catch (e) {
673673
if (e instanceof Error) {
674674
req.executionError = e
675675
}
676-
res.send({ healthy: false })
676+
return res.send({ healthy: false })
677677
}
678678
})
679679
})

src/http/routes/health/healthcheck.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ export default async function routes(fastify: FastifyInstance) {
1313
async (req, res) => {
1414
try {
1515
await req.storage.healthcheck()
16-
res.send({ healthy: true })
16+
return res.send({ healthy: true })
1717
} catch (e) {
1818
if (e instanceof Error) {
1919
req.executionError = e
2020
}
21-
res.send({ healthy: false })
21+
return res.send({ healthy: false })
2222
}
2323
}
2424
)

src/internal/database/migrations/migrate.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { getTenantConfig, TenantMigrationStatus } from '../tenant'
1111
import { multitenantKnex } from '../multitenant-db'
1212
import { ProgressiveMigrations } from './progressive'
1313
import { ResetMigrationsOnTenant, RunMigrationsOnTenants } from '@storage/events'
14-
import { ERRORS, StorageBackendError } from '@internal/errors'
14+
import { ERRORS } from '@internal/errors'
1515
import { DBMigration } from './types'
1616
import { getSslSettings } from '../ssl'
1717
import { MigrationTransformer, DisableConcurrentIndexTransformer } from './transformers'
@@ -699,11 +699,19 @@ function runMigrations({
699699
`Migration failed. Reason: ${(e as Error).message}`,
700700
e as MigrationError
701701
).withMetadata({
702-
migrationsToRun: migrationsToRun,
702+
currentMigrations: appliedMigrations.map((migration) => ({
703+
id: migration.id,
704+
name: migration.name,
705+
hash: migration.hash,
706+
})),
707+
migrationsToRun: migrationsToRun.map((migration) => ({
708+
id: migration.id,
709+
name: migration.name,
710+
hash: migration.hash,
711+
})),
703712
migrationId: migration.id,
704713
migrationName: migration.name,
705714
migrationHash: migration.hash,
706-
migrationSql: migration.sql,
707715
})
708716
}
709717
}

0 commit comments

Comments
 (0)