Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ sourceMapSupport.install({
},
})

closeWithGrace(async ({ err }) => {
if (err) {
console.error(chalk.red(err))
console.error(chalk.red(err.stack))
process.exit(1)
}
})

if (process.env.MOCKS === 'true') {
await import('./tests/mocks/index.ts')
}
Expand Down
14 changes: 12 additions & 2 deletions server/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import crypto from 'node:crypto'
import { createRequestHandler } from '@remix-run/express'
import { type ServerBuild } from '@remix-run/node'
import Sentry from '@sentry/remix'
import { ip as ipAddress } from 'address'
import chalk from 'chalk'
import closeWithGrace from 'close-with-grace'
Expand All @@ -15,8 +16,9 @@ const MODE = process.env.NODE_ENV ?? 'development'
const IS_PROD = MODE === 'production'
const IS_DEV = MODE === 'development'
const ALLOW_INDEXING = process.env.ALLOW_INDEXING !== 'false'
const SENTRY_ENABLED = IS_PROD && process.env.SENTRY_DSN

if (IS_PROD && process.env.SENTRY_DSN) {
if (SENTRY_ENABLED) {
void import('./utils/monitoring.js').then(({ init }) => init())
}

Expand Down Expand Up @@ -276,8 +278,16 @@ ${chalk.bold('Press Ctrl+C to stop')}
)
})

closeWithGrace(async () => {
closeWithGrace(async ({ err }) => {
await new Promise((resolve, reject) => {
server.close((e) => (e ? reject(e) : resolve('ok')))
})
if (err) {
console.error(chalk.red(err))
console.error(chalk.red(err.stack))
if (SENTRY_ENABLED) {
Sentry.captureException(err)
await Sentry.flush(500)
}
}
})