7
7
import { PassThrough } from 'node:stream' ;
8
8
9
9
import type { AppLoadContext , EntryContext , DataFunctionArgs } from '@remix-run/node' ;
10
- import { Response } from '@remix-run/node' ;
10
+ import { json } from '@remix-run/node' ;
11
11
import { RemixServer } from '@remix-run/react' ;
12
- import isbot from 'isbot' ;
13
12
import { renderToPipeableStream } from 'react-dom/server' ;
14
13
import * as Sentry from '@sentry/remix' ;
15
14
@@ -19,7 +18,6 @@ Sentry.init({
19
18
dsn : process . env . E2E_TEST_DSN ,
20
19
// Performance Monitoring
21
20
tracesSampleRate : 1.0 , // Capture 100% of the transactions, reduce in production!
22
- isRemixV2 : true ,
23
21
} ) ;
24
22
25
23
export function handleError ( error : unknown , { request } : DataFunctionArgs ) : void {
@@ -37,47 +35,7 @@ export default function handleRequest(
37
35
remixContext : EntryContext ,
38
36
loadContext : AppLoadContext ,
39
37
) {
40
- return isbot ( request . headers . get ( 'user-agent' ) )
41
- ? handleBotRequest ( request , responseStatusCode , responseHeaders , remixContext )
42
- : handleBrowserRequest ( request , responseStatusCode , responseHeaders , remixContext ) ;
43
- }
44
-
45
- function handleBotRequest (
46
- request : Request ,
47
- responseStatusCode : number ,
48
- responseHeaders : Headers ,
49
- remixContext : EntryContext ,
50
- ) {
51
- return new Promise ( ( resolve , reject ) => {
52
- const { pipe, abort } = renderToPipeableStream (
53
- < RemixServer context = { remixContext } url = { request . url } abortDelay = { ABORT_DELAY } /> ,
54
- {
55
- onAllReady ( ) {
56
- const body = new PassThrough ( ) ;
57
-
58
- responseHeaders . set ( 'Content-Type' , 'text/html' ) ;
59
-
60
- resolve (
61
- new Response ( body , {
62
- headers : responseHeaders ,
63
- status : responseStatusCode ,
64
- } ) ,
65
- ) ;
66
-
67
- pipe ( body ) ;
68
- } ,
69
- onShellError ( error : unknown ) {
70
- reject ( error ) ;
71
- } ,
72
- onError ( error : unknown ) {
73
- responseStatusCode = 500 ;
74
- console . error ( error ) ;
75
- } ,
76
- } ,
77
- ) ;
78
-
79
- setTimeout ( abort , ABORT_DELAY ) ;
80
- } ) ;
38
+ handleBrowserRequest ( request , responseStatusCode , responseHeaders , remixContext ) ;
81
39
}
82
40
83
41
function handleBrowserRequest (
@@ -96,7 +54,7 @@ function handleBrowserRequest(
96
54
responseHeaders . set ( 'Content-Type' , 'text/html' ) ;
97
55
98
56
resolve (
99
- new Response ( body , {
57
+ json ( body , {
100
58
headers : responseHeaders ,
101
59
status : responseStatusCode ,
102
60
} ) ,
0 commit comments