Skip to content

Commit

Permalink
fix: removed special case for edge
Browse files Browse the repository at this point in the history
  • Loading branch information
wyattjoh committed May 11, 2024
1 parent abbabfa commit 823997e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
21 changes: 3 additions & 18 deletions packages/next/src/server/base-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ export default abstract class Server<
this.handleRequestImpl(req, res, parsedUrl).finally(() => {
if (!span) return

const isRSCRequest = isRSCRequestCheck(req)
const isRSCRequest = getRequestMeta(req, 'isRSCRequest')
span.setAttributes({
'http.status_code': res.statusCode,
'next.rsc': isRSCRequest,
Expand Down Expand Up @@ -1305,7 +1305,7 @@ export default abstract class Server<
resolvedPathname: string
): void {
const baseVaryHeader = `${RSC_HEADER}, ${NEXT_ROUTER_STATE_TREE}, ${NEXT_ROUTER_PREFETCH_HEADER}`
const isRSCRequest = isRSCRequestCheck(req)
const isRSCRequest = getRequestMeta(req, 'isRSCRequest')

let addedNextUrlToVary = false

Expand Down Expand Up @@ -1475,7 +1475,7 @@ export default abstract class Server<
}

// Don't delete headers[RSC] yet, it still needs to be used in renderToHTML later
const isRSCRequest = isRSCRequestCheck(req)
const isRSCRequest = getRequestMeta(req, 'isRSCRequest') ?? false

const { routeModule } = components

Expand Down Expand Up @@ -3121,18 +3121,3 @@ export default abstract class Server<
return this.renderError(null, req, res, pathname!, query, setHeaders)
}
}

/**
* Check if the request is a RSC request. This is only attached after the
* `handle` method is called, or at least the `requestAdapter.adapt` is called
* on the request.
*/
export function isRSCRequestCheck(req: BaseNextRequest): boolean {
// In edge, we can just check the header, as it's not set via request
// metadata.
if (process.env.NEXT_RUNTIME === 'edge') {
return req.headers[RSC_HEADER.toLowerCase()] === '1'
} else {
return getRequestMeta(req, 'isRSCRequest') === true
}
}
4 changes: 2 additions & 2 deletions packages/next/src/server/next-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import type {
NextEnabledDirectories,
BaseRequestHandler,
} from './base-server'
import BaseServer, { NoFallbackError, isRSCRequestCheck } from './base-server'
import BaseServer, { NoFallbackError } from './base-server'
import { getMaybePagePath, getPagePath, requireFontManifest } from './require'
import { denormalizePagePath } from '../shared/lib/page-path/denormalize-page-path'
import { normalizePagePath } from '../shared/lib/page-path/normalize-page-path'
Expand Down Expand Up @@ -1133,7 +1133,7 @@ export default class NextNodeServer extends BaseServer<

// NOTE: this is only attached after handle has started, this runs
// after the response has been sent, so it should have it set.
const isRSC = isRSCRequestCheck(normalizedReq)
const isRSC = getRequestMeta(normalizedReq, 'isRSCRequest')

const reqEnd = Date.now()
const fetchMetrics = normalizedReq.fetchMetrics || []
Expand Down

0 comments on commit 823997e

Please sign in to comment.