Skip to content

Commit cb71343

Browse files
authored
Error Logging (#735)
add error logging directly to console
1 parent d9fa23a commit cb71343

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

app/entry.server.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { getEnv, init } from './utils/env.server.ts'
1313
import { getInstanceInfo } from './utils/litefs.server.ts'
1414
import { NonceProvider } from './utils/nonce-provider.ts'
1515
import { makeTimings } from './utils/timing.server.ts'
16+
import chalk from 'chalk'
1617

1718
const ABORT_DELAY = 5000
1819

@@ -97,9 +98,16 @@ export function handleError(
9798
error: unknown,
9899
{ request }: LoaderFunctionArgs | ActionFunctionArgs,
99100
): void {
101+
// Skip capturing if the request is aborted as Remix docs suggest
102+
// Ref: https://remix.run/docs/en/main/file-conventions/entry.server#handleerror
103+
if (request.signal.aborted) {
104+
return
105+
}
100106
if (error instanceof Error) {
107+
console.error(chalk.red(error.stack))
101108
Sentry.captureRemixServerException(error, 'remix.server', request)
102109
} else {
110+
console.error(chalk.red(error))
103111
Sentry.captureException(error)
104112
}
105113
}

0 commit comments

Comments
 (0)