MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / register

Function register

web/instrumentation.ts:13–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11import { logger } from '@/util/logger'
12
13export async function register() {
14 // Handle unhandled promise rejections (async errors that aren't caught)
15 process.on(
16 'unhandledRejection',
17 (reason: unknown, promise: Promise<unknown>) => {
18 logger.error(
19 {
20 reason:
21 reason instanceof Error
22 ? { message: reason.message, stack: reason.stack }
23 : reason,
24 promise: String(promise),
25 },
26 '[CRITICAL] Unhandled Promise Rejection',
27 )
28 // Don't exit - let the process continue to handle other requests
29 // In production, Render will restart if there's a real crash
30 },
31 )
32
33 // Handle uncaught exceptions (sync errors that aren't caught)
34 process.on('uncaughtException', (error: Error, origin: string) => {
35 logger.error(
36 {
37 message: error.message,
38 stack: error.stack,
39 origin,
40 },
41 '[CRITICAL] Uncaught Exception',
42 )
43 // Don't exit - let the process continue to handle other requests
44 // This prevents a single bad request from taking down the entire server
45 })
46
47 logger.info({}, '[Instrumentation] Global error handlers registered')
48
49 // DB-touching admission module uses `postgres`, which imports Node built-ins
50 // like `crypto`. Gate on NEXT_RUNTIME so the edge bundle doesn't try to
51 // resolve them.
52 if (process.env.NEXT_RUNTIME === 'nodejs') {
53 const { startFreeSessionAdmission } = await import(
54 '@/server/free-session/admission'
55 )
56 startFreeSessionAdmission()
57 }
58}

Callers

nothing calls this directly

Calls 2

onMethod · 0.65

Tested by

no test coverage detected