@@ -23,10 +23,6 @@ global.ENV = getEnv()
23
23
24
24
initCron ( )
25
25
26
- if ( ENV . MODE === 'production' && ENV . SENTRY_DSN ) {
27
- import ( './utils/monitoring.server.ts' ) . then ( ( { init } ) => init ( ) )
28
- }
29
-
30
26
type DocRequestArgs = Parameters < HandleDocumentRequestFunction >
31
27
32
28
export default async function handleRequest ( ...args : DocRequestArgs ) {
@@ -43,11 +39,15 @@ export default async function handleRequest(...args: DocRequestArgs) {
43
39
responseHeaders . set ( 'fly-primary-instance' , primaryInstance )
44
40
responseHeaders . set ( 'fly-instance' , currentInstance )
45
41
42
+ if ( process . env . NODE_ENV === 'production' && process . env . SENTRY_DSN ) {
43
+ responseHeaders . append ( 'Document-Policy' , 'js-profiling' )
44
+ }
45
+
46
46
const callbackName = isbot ( request . headers . get ( 'user-agent' ) )
47
47
? 'onAllReady'
48
48
: 'onShellReady'
49
49
50
- const nonce = String ( loadContext . cspNonce ) ?? undefined
50
+ const nonce = loadContext . cspNonce ?. toString ( ) ?? ''
51
51
return new Promise ( async ( resolve , reject ) => {
52
52
let didError = false
53
53
// NOTE: this timing will only include things that are rendered in the shell
@@ -106,7 +106,12 @@ export function handleError(
106
106
}
107
107
if ( error instanceof Error ) {
108
108
console . error ( chalk . red ( error . stack ) )
109
- Sentry . captureRemixServerException ( error , 'remix.server' , request )
109
+ void Sentry . captureRemixServerException (
110
+ error ,
111
+ 'remix.server' ,
112
+ request ,
113
+ true ,
114
+ )
110
115
} else {
111
116
console . error ( chalk . red ( error ) )
112
117
Sentry . captureException ( error )
0 commit comments