Skip to content

Commit

Permalink
fix: merge issues
Browse files Browse the repository at this point in the history
  • Loading branch information
wyattjoh committed Jun 10, 2024
1 parent 919a2c7 commit 15e9436
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub async fn get_app_route_entry(
"VAR_DEFINITION_PATHNAME" => pathname.clone(),
"VAR_DEFINITION_FILENAME" => path.file_stem().await?.as_ref().unwrap().as_str().into(),
// TODO(alexkirsz) Is this necessary?
"VAR_DEFINITION_BUNDLE_PATH" => "".to_string(),
"VAR_DEFINITION_BUNDLE_PATH" => "".to_string().into(),
"VAR_RESOLVED_PAGE_PATH" => path.to_string().await?.clone_value(),
"VAR_USERLAND" => INNER.into(),
},
Expand Down
4 changes: 1 addition & 3 deletions packages/next/src/server/after/after.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { getExpectedRequestStore } from '../../client/components/request-async-storage.external'
import { staticGenerationAsyncStorage } from '../../client/components/static-generation-async-storage.external'
import { StaticGenBailoutError } from '../../client/components/static-generation-bailout'
import { getPathname } from '../../lib/url'

import { markCurrentScopeAsDynamic } from '../app-render/dynamic-rendering'

Expand All @@ -27,9 +26,8 @@ export function unstable_after<T>(task: AfterTask<T>) {

if (staticGenerationStore) {
if (staticGenerationStore.forceStatic) {
const pathname = getPathname(staticGenerationStore.urlPathname)
throw new StaticGenBailoutError(
`Route ${pathname} with \`dynamic = "force-static"\` couldn't be rendered statically because it used \`${callingExpression}\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`
`Route ${staticGenerationStore.url?.pathname ?? staticGenerationStore.page} with \`dynamic = "force-static"\` couldn't be rendered statically because it used \`${callingExpression}\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`
)
} else {
markCurrentScopeAsDynamic(staticGenerationStore, callingExpression)
Expand Down
9 changes: 4 additions & 5 deletions packages/next/src/server/app-render/app-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1159,9 +1159,8 @@ async function renderToHTMLOrFlightImpl(
</HeadManagerContext.Provider>
)

const { stream: resumeStream } = await resumeRenderer.render(
resumeChildren
)
const { stream: resumeStream } =
await resumeRenderer.render(resumeChildren)
// First we write everything from the prerender, then we write everything from the aborted resume render
renderedHTMLStream = chainStreams(stream, resumeStream)
}
Expand Down Expand Up @@ -1283,8 +1282,8 @@ async function renderToHTMLOrFlightImpl(
const errorType = is404
? 'not-found'
: hasRedirectError
? 'redirect'
: undefined
? 'redirect'
: undefined

const [errorPreinitScripts, errorBootstrapScript] = getRequiredScripts(
buildManifest,
Expand Down
24 changes: 12 additions & 12 deletions packages/next/src/server/base-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export interface MiddlewareRoutingItem {

export type RouteHandler<
ServerRequest extends BaseNextRequest = BaseNextRequest,
ServerResponse extends BaseNextResponse = BaseNextResponse
ServerResponse extends BaseNextResponse = BaseNextResponse,
> = (
req: ServerRequest,
res: ServerResponse,
Expand Down Expand Up @@ -263,7 +263,7 @@ export interface BaseRequestHandler<
ServerRequest extends BaseNextRequest | IncomingMessage = BaseNextRequest,
ServerResponse extends
| BaseNextResponse
| HTTPServerResponse = BaseNextResponse
| HTTPServerResponse = BaseNextResponse,
> {
(
req: ServerRequest,
Expand All @@ -274,7 +274,7 @@ export interface BaseRequestHandler<

export type RequestContext<
ServerRequest extends BaseNextRequest = BaseNextRequest,
ServerResponse extends BaseNextResponse = BaseNextResponse
ServerResponse extends BaseNextResponse = BaseNextResponse,
> = {
req: ServerRequest
res: ServerResponse
Expand Down Expand Up @@ -312,7 +312,7 @@ export type NextEnabledDirectories = {
export default abstract class Server<
ServerOptions extends Options = Options,
ServerRequest extends BaseNextRequest = BaseNextRequest,
ServerResponse extends BaseNextResponse = BaseNextResponse
ServerResponse extends BaseNextResponse = BaseNextResponse,
> {
public readonly hostname?: string
public readonly fetchHostname?: string
Expand Down Expand Up @@ -953,8 +953,8 @@ export default abstract class Server<
req.headers['x-forwarded-port'] ??= this.port
? this.port.toString()
: isHttps
? '443'
: '80'
? '443'
: '80'
req.headers['x-forwarded-proto'] ??= isHttps ? 'https' : 'http'
req.headers['x-forwarded-for'] ??= originalRequest?.socket?.remoteAddress

Expand Down Expand Up @@ -1774,8 +1774,8 @@ export default abstract class Server<
typeof fallbackField === 'string'
? 'static'
: fallbackField === null
? 'blocking'
: fallbackField,
? 'blocking'
: fallbackField,
}
}

Expand Down Expand Up @@ -2821,10 +2821,10 @@ export default abstract class Server<
isOnDemandRevalidate
? 'REVALIDATED'
: cacheEntry.isMiss
? 'MISS'
: cacheEntry.isStale
? 'STALE'
: 'HIT'
? 'MISS'
: cacheEntry.isStale
? 'STALE'
: 'HIT'
)
}

Expand Down
9 changes: 4 additions & 5 deletions packages/next/src/server/lib/patch-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ function createPatchedFetcher(
return typeof init?.next?.[field] !== 'undefined'
? init?.next?.[field]
: isRequestInput
? (input as any).next?.[field]
: undefined
? (input as any).next?.[field]
: undefined
}
// RequestInit doesn't keep extra fields e.g. next so it's
// only available if init is used separate
Expand Down Expand Up @@ -632,9 +632,8 @@ function createPatchedFetcher(
let isForegroundRevalidate = false

if (cacheKey && staticGenerationStore.incrementalCache) {
handleUnlock = await staticGenerationStore.incrementalCache.lock(
cacheKey
)
handleUnlock =
await staticGenerationStore.incrementalCache.lock(cacheKey)

const entry = staticGenerationStore.isOnDemandRevalidate
? null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export function unstable_cache<T extends Callback>(
const incrementalCache = maybeIncrementalCache

const { pathname, searchParams } = new URL(
store?.urlPathname || '/',
store?.url?.pathname ?? store?.page ?? '/',
'http://n'
)
const sortedSearchKeys = [...searchParams.keys()].sort((a, b) => {
Expand Down

0 comments on commit 15e9436

Please sign in to comment.