11import { PassThrough } from 'node:stream'
2+ import { createReadableStreamFromReadable } from '@react-router/node'
3+
4+ import * as Sentry from '@sentry/node'
5+ import chalk from 'chalk'
6+ import { isbot } from 'isbot'
7+ import { renderToPipeableStream } from 'react-dom/server'
28import {
3- createReadableStreamFromReadable ,
9+ ServerRouter ,
410 type LoaderFunctionArgs ,
511 type ActionFunctionArgs ,
612 type HandleDocumentRequestFunction ,
7- } from '@remix-run/node'
8- import { RemixServer } from '@remix-run/react'
9- import * as Sentry from '@sentry/remix'
10- import chalk from 'chalk'
11- import { isbot } from 'isbot'
12- import { renderToPipeableStream } from 'react-dom/server'
13+ } from 'react-router'
1314import { getEnv , init } from './utils/env.server.ts'
1415import { getInstanceInfo } from './utils/litefs.server.ts'
1516import { NonceProvider } from './utils/nonce-provider.ts'
1617import { makeTimings } from './utils/timing.server.ts'
1718
18- const ABORT_DELAY = 5000
19+ export const streamTimeout = 5000
1920
2021init ( )
2122global . ENV = getEnv ( )
@@ -27,7 +28,7 @@ export default async function handleRequest(...args: DocRequestArgs) {
2728 request ,
2829 responseStatusCode ,
2930 responseHeaders ,
30- remixContext ,
31+ reactRouterContext ,
3132 loadContext ,
3233 ] = args
3334 const { currentInstance, primaryInstance } = await getInstanceInfo ( )
@@ -53,7 +54,11 @@ export default async function handleRequest(...args: DocRequestArgs) {
5354
5455 const { pipe, abort } = renderToPipeableStream (
5556 < NonceProvider value = { nonce } >
56- < RemixServer context = { remixContext } url = { request . url } />
57+ < ServerRouter
58+ nonce = { nonce }
59+ context = { reactRouterContext }
60+ url = { request . url }
61+ />
5762 </ NonceProvider > ,
5863 {
5964 [ callbackName ] : ( ) => {
@@ -78,7 +83,7 @@ export default async function handleRequest(...args: DocRequestArgs) {
7883 } ,
7984 )
8085
81- setTimeout ( abort , ABORT_DELAY )
86+ setTimeout ( abort , streamTimeout + 5000 )
8287 } )
8388}
8489
@@ -103,12 +108,7 @@ export function handleError(
103108 }
104109 if ( error instanceof Error ) {
105110 console . error ( chalk . red ( error . stack ) )
106- void Sentry . captureRemixServerException (
107- error ,
108- 'remix.server' ,
109- request ,
110- true ,
111- )
111+ void Sentry . captureException ( error )
112112 } else {
113113 console . error ( error )
114114 Sentry . captureException ( error )
0 commit comments