Skip to content

Commit

Permalink
Merge branch 'canary' into wbinnssmith/remove-unit
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] committed Sep 1, 2023
2 parents b8abe70 + 9adc791 commit b566fac
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 66 deletions.
110 changes: 68 additions & 42 deletions .github/ISSUE_TEMPLATE/1.bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,43 @@ body:
- type: markdown
attributes:
value: |
*Note:* If you leave out sections, the issue might be moved to the ["Help" section](https://github.com/vercel/next.js/discussions/categories/help).
[examples](https://github.com/vercel/next.js/tree/canary/examples) related issue should be reported using [this](https://github.com/vercel/next.js/issues/new?assignees=&labels=type%3A+example%2Ctemplate%3A+bug&template=2.example_bug_report.yml) issue template instead.
This template is to report Next.js bugs. [Examples](https://github.com/vercel/next.js/tree/canary/examples) related issues should be reported using [this](https://github.com/vercel/next.js/issues/new?assignees=&labels=type%3A+example%2Ctemplate%3A+bug&template=2.example_bug_report.yml) issue template instead.
Feature requests should be opened as [discussions](https://github.com/vercel/next.js/discussions/new?category=ideas). [Read more](https://github.com/vercel/next.js/blob/canary/contributing/core/adding-features.md).
Before opening a new issue, please do a [search](https://github.com/vercel/next.js/issues) of existing issues and :+1: upvote the existing issue instead. This will result in a quicker resolution.
If you need help with your own project, you can:
- Start a discussion in the ["Help" section](https://github.com/vercel/next.js/discussions/categories/help)
- Ask a question on the [Next.js Discord](https://discord.com/invite/nextjs) server
- type: input
attributes:
label: Link to the code that reproduces this issue or a replay of the bug
description: |
A link to a **public** [GitHub repository](https://github.com/vercel/next.js/tree/canary/examples/reproduction-template) or a [CodeSandbox](https://codesandbox.io/p/sandbox/github/vercel/next.js/tree/canary/examples/reproduction-template) minimal reproduction. Minimal reproductions should be created from our [bug report template with `npx create-next-app -e reproduction-template`](https://github.com/vercel/next.js/tree/canary/examples/reproduction-template) and should include only changes that contribute to the issue. To report a Pages Router related issue, you can use these templates: [`npx create-next-app -e reproduction-template-pages`](https://github.com/vercel/next.js/tree/canary/examples/reproduction-template-pages) or [CodeSandbox](https://codesandbox.io/p/sandbox/github/vercel/next.js/tree/canary/examples/reproduction-template-pages)
If a minimal reproduction can't be created, please share a [replay](https://www.replay.io/) of the bug which doesn't require sharing a private repo.
**Skipping this/providing an invalid link will result in the issue being closed**
placeholder: 'https://github.com/user/my-minimal-nextjs-issue-reproduction'
validations:
required: true
- type: textarea
attributes:
label: To Reproduce
description: A step-by-step description of how to reproduce the issue, based on the linked reproduction. Screenshots can be provided in the issue body below. If using code blocks, make sure that [syntax highlighting is correct](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#syntax-highlighting) and double check that the rendered preview is not broken.
placeholder: |
1. Start the application in development (next dev)
2. Click X
3. Y will happen
validations:
required: true
- type: textarea
attributes:
label: Current vs. Expected behavior
description: A clear and concise description of what the bug is, and what you expected to happen.
placeholder: 'Following the steps from the previous section, I expected A to happen, but I observed B instead'
validations:
required: true
- type: checkboxes
attributes:
label: Verify canary release
Expand All @@ -20,13 +54,32 @@ body:
label: Provide environment information
description: Please run `next info` in the root directory of your project and paste the results. You might need to use `npx --no-install next info` if next is not in the current PATH.
render: bash
placeholder: |
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 22.5.0
Binaries:
Node: 18.17.1
npm: 9.5.1
Yarn: 1.22.19
pnpm: N/A
Relevant Packages:
next: 13.4.20
eslint-config-next: 13.4.20
react: 18.2.0
react-dom: 18.2.0
typescript: 5.2.2
Next.js Config:
output: N/A
validations:
required: true
- type: dropdown
attributes:
label: Which area(s) of Next.js are affected? (leave empty if unsure)
label: Which area(s) are affected? (Select all that apply)
multiple: true
options:
- 'Not sure'
- 'App Router'
- 'CLI (create-next-app)'
- 'Data fetching (gS(S)P, getInitialProps)'
Expand All @@ -49,47 +102,20 @@ body:
- 'SWC transpilation'
- 'Turbopack (--turbo)'
- 'TypeScript (plugin, built-in types)'
- type: input
attributes:
label: Link to the code that reproduces this issue or a replay of the bug
description: |
A link to a [GitHub repository](https://github.com/vercel/next.js/tree/canary/examples/reproduction-template) or a [CodeSandbox](https://codesandbox.io/p/sandbox/github/vercel/next.js/tree/canary/examples/reproduction-template) minimal reproduction. Minimal reproductions should be created from our [bug report template with `npx create-next-app -e reproduction-template`](https://github.com/vercel/next.js/tree/canary/examples/reproduction-template) and should include only changes that contribute to the issue.
If a minimal reproduction can't be created please share a [replay](https://www.replay.io/) of the bug which doesn't require sharing a private repo.
To report a Pages Router related issue, you can use these templates: [CodeSandbox](https://codesandbox.io/p/sandbox/github/vercel/next.js/tree/canary/examples/reproduction-template-pages) or [`npx create-next-app -e reproduction-template-pages`](https://github.com/vercel/next.js/tree/canary/examples/reproduction-template-pages)
validations:
required: true
- type: textarea
attributes:
label: To Reproduce
description: Steps to reproduce the behavior, please provide a clear description of how to reproduce the issue, based on the linked minimal reproduction. Screenshots can be provided in the issue body below. If using code blocks, make sure that [syntax highlighting is correct](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#syntax-highlighting) and double check that the rendered preview is not broken.
validations:
required: true
- type: textarea
attributes:
label: Describe the Bug
description: A clear and concise description of what the bug is.
validations:
required: true
- type: textarea
attributes:
label: Expected Behavior
description: A clear and concise description of what you expected to happen.
validations:
required: true
- type: markdown
attributes:
value: Before posting the issue go through the steps you've written down to make sure the steps provided are detailed and clear.
- type: markdown
attributes:
value: Contributors should be able to follow the steps provided in order to reproduce the bug.
- type: markdown
attributes:
value: These steps are used to add integration tests to ensure the same issue does not happen again. Thanks in advance!
- type: input
attributes:
label: Which browser are you using? (if relevant)
description: 'Please specify the exact version. For example: Chrome 100.0.4878.0'
- type: input
value: |
Another way you can help the maintainers' job is to pinpoint the `canary` version of `next` that introduced the issue. Check out our [releases](https://github.com/vercel/next.js/releases), and try to find the first `canary` release that introduced the issue. This will help us narrow down the scope of the issue, and possibly point to the PR/code change that introduced it. You can install a specific version of `next` by running `npm install next@<version>`.
- type: textarea
attributes:
label: How are you deploying your application? (if relevant)
description: 'For example: next start, Vercel, Other platform'
label: Additional context
description: |
Any extra information that might help us investigate. For example, where are you deploying your application (Vercel, Docker, other platform)? Is it only reproducible on that platform, or locally too? Is the issue only happening in a specific browser? etc.
placeholder: |
I tested my reproduction against different canary releases, and the first one that introduced the bug was "13.4.20-canary.13", since reverting to "13.4.20-canary.12" works.
or
I am hosting via Docker with the recommended `output: "standalone"` option", and if I remove that option or try a different hosting option, I cannot reproduce the same issue.
2 changes: 1 addition & 1 deletion .github/actions/issue-validator/autolabel/index.mjs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions .github/actions/issue-validator/src/autolabel.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ async function run() {
*/
const toAdd = []

// https://github.com/vercel/next.js/blame/canary/.github/ISSUE_TEMPLATE/1.bug_report.yml
// https://github.com/vercel/next.js/blob/canary/.github/ISSUE_TEMPLATE/1.bug_report.yml?plain=1

const matchSection = issue_body
.split('Which area(s) of Next.js are affected? (leave empty if unsure)')[1]
?.split('Link to the code that reproduces this issue')[0]
.split('Which area(s) are affected? (Select all that apply)')[1]
?.split('Another way you can help the maintainers')[0]

if (!matchSection) {
console.log(
Expand Down
2 changes: 2 additions & 0 deletions .github/actions/issue-validator/src/repro-link.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ async function run() {
const { body: issue_body } = issue
if (!issue_body) return console.log('Could not get issue body, exiting')

// https://github.com/vercel/next.js/blob/canary/.github/ISSUE_TEMPLATE/1.bug_report.yml?plain=1

const start =
'### Link to the code that reproduces this issue or a replay of the bug'
const end = '### To Reproduce'
Expand Down
4 changes: 4 additions & 0 deletions examples/with-docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/export/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ export default async function exportPage({
results.fromBuildExportRevalidate = revalidate

if (revalidate !== 0) {
const cacheTags = (curRenderOpts as any).fetchTags
const cacheTags = metadata.fetchTags
const headers = cacheTags
? {
[NEXT_CACHE_TAGS_HEADER]: cacheTags,
Expand Down
42 changes: 26 additions & 16 deletions packages/next/src/server/app-render/app-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,13 @@ export async function renderToHTMLOrFlight(
supportsDynamicHTML,
nextConfigOutput,
serverActionsBodySizeLimit,
buildId,
deploymentId,
appDirDevErrorLogger,
} = renderOpts

const extraRenderResultMeta: RenderResultMetadata = {}

const appUsingSizeAdjust = !!nextFontManifest?.appUsingSizeAdjust

const clientReferenceManifest = renderOpts.clientReferenceManifest!
Expand All @@ -195,21 +200,21 @@ export async function renderToHTMLOrFlight(
_source: 'serverComponentsRenderer',
dev,
isNextExport,
errorLogger: renderOpts.appDirDevErrorLogger,
errorLogger: appDirDevErrorLogger,
capturedErrors,
})
const flightDataRendererErrorHandler = createErrorHandler({
_source: 'flightDataRenderer',
dev,
isNextExport,
errorLogger: renderOpts.appDirDevErrorLogger,
errorLogger: appDirDevErrorLogger,
capturedErrors,
})
const htmlRendererErrorHandler = createErrorHandler({
_source: 'htmlRenderer',
dev,
isNextExport,
errorLogger: renderOpts.appDirDevErrorLogger,
errorLogger: appDirDevErrorLogger,
capturedErrors,
allCapturedErrors,
})
Expand Down Expand Up @@ -246,7 +251,7 @@ export async function renderToHTMLOrFlight(
)
}
staticGenerationStore.fetchMetrics = []
;(renderOpts as any).fetchMetrics = staticGenerationStore.fetchMetrics
extraRenderResultMeta.fetchMetrics = staticGenerationStore.fetchMetrics

const requestStore = requestAsyncStorage.getStore()
if (!requestStore) {
Expand Down Expand Up @@ -392,8 +397,8 @@ export async function renderToHTMLOrFlight(
qs += `?v=${DEV_REQUEST_TS}`
}

if (renderOpts.deploymentId) {
qs += `${isDev ? '&' : '?'}dpl=${renderOpts.deploymentId}`
if (deploymentId) {
qs += `${isDev ? '&' : '?'}dpl=${deploymentId}`
}
return qs
}
Expand Down Expand Up @@ -1247,7 +1252,7 @@ export async function renderToHTMLOrFlight(
).map((path) => path.slice(1)) // remove the '' (root) segment
}

const buildIdFlightDataPair = [renderOpts.buildId, flightData]
const buildIdFlightDataPair = [buildId, flightData]

// For app dir, use the bundled version of Fizz renderer (renderToReadableStream)
// which contains the subset React.
Expand Down Expand Up @@ -1360,7 +1365,7 @@ export async function renderToHTMLOrFlight(
<>
{styles}
<AppRouter
buildId={renderOpts.buildId}
buildId={buildId}
assetPrefix={assetPrefix}
initialCanonicalUrl={pathname}
initialTree={initialTree}
Expand Down Expand Up @@ -1650,7 +1655,7 @@ export async function renderToHTMLOrFlight(
// so we create a not found page with AppRouter
return (
<AppRouter
buildId={renderOpts.buildId}
buildId={buildId}
assetPrefix={assetPrefix}
initialCanonicalUrl={pathname}
initialTree={initialTree}
Expand Down Expand Up @@ -1723,24 +1728,30 @@ export async function renderToHTMLOrFlight(
await bodyResult({
asNotFound: true,
tree: notFoundLoaderTree,
})
}),
{ ...extraRenderResultMeta }
)
} else if (actionRequestResult) {
actionRequestResult.extendMetadata(extraRenderResultMeta)
return actionRequestResult
}

const renderResult = new RenderResult(
await bodyResult({
asNotFound: pagePath === '/404',
tree: loaderTree,
})
}),
{ ...extraRenderResultMeta }
)

if (staticGenerationStore.pendingRevalidates) {
await Promise.all(staticGenerationStore.pendingRevalidates)
}
addImplicitTags(staticGenerationStore)
;(renderOpts as any).fetchTags = staticGenerationStore.tags?.join(',')
extraRenderResultMeta.fetchTags = staticGenerationStore.tags?.join(',')
renderResult.extendMetadata({
fetchTags: extraRenderResultMeta.fetchTags,
})

if (staticGenerationStore.isStaticGeneration) {
const htmlResult = await streamToBufferedResult(renderResult)
Expand All @@ -1761,10 +1772,9 @@ export async function renderToHTMLOrFlight(
staticGenerationStore.revalidate = 0
}

const extraRenderResultMeta: RenderResultMetadata = {
pageData: filteredFlightData,
revalidate: staticGenerationStore.revalidate ?? defaultRevalidate,
}
extraRenderResultMeta.pageData = filteredFlightData
extraRenderResultMeta.revalidate =
staticGenerationStore.revalidate ?? defaultRevalidate

// provide bailout info for debugging
if (extraRenderResultMeta.revalidate === 0) {
Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/server/base-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2116,15 +2116,15 @@ export default abstract class Server<ServerOptions extends Options = Options> {
const { metadata } = result

// Add any fetch tags that were on the page to the response headers.
const cacheTags = (renderOpts as any).fetchTags
const cacheTags = metadata.fetchTags
if (cacheTags) {
headers = {
[NEXT_CACHE_TAGS_HEADER]: cacheTags,
}
}

// Pull any fetch metrics from the render onto the request.
;(req as any).fetchMetrics = (renderOpts as any).fetchMetrics
;(req as any).fetchMetrics = metadata.fetchMetrics

// we don't throw static to dynamic errors in dev as isSSG
// is a best guess in dev since we don't have the prerender pass
Expand Down
7 changes: 7 additions & 0 deletions packages/next/src/server/render-result.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { StaticGenerationStore } from '../client/components/static-generation-async-storage'
import { pipeReadable, PipeTarget } from './pipe-readable'

type ContentTypeOption = string | undefined
Expand All @@ -9,6 +10,8 @@ export type RenderResultMetadata = {
assetQueryString?: string
isNotFound?: boolean
isRedirect?: boolean
fetchMetrics?: StaticGenerationStore['fetchMetrics']
fetchTags?: string
}

type RenderResultResponse = string | ReadableStream<Uint8Array> | null
Expand Down Expand Up @@ -58,6 +61,10 @@ export default class RenderResult {
this.metadata = metadata
}

public extendMetadata(metadata: RenderResultMetadata) {
Object.assign(this.metadata, metadata)
}

/**
* Returns true if the response is null. It can be null if the response was
* not found or was already sent.
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/web-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { Params } from '../shared/lib/router/utils/route-matcher'
import type { PayloadOptions } from './send-payload'
import type { LoadComponentsReturnType } from './load-components'
import type { BaseNextRequest, BaseNextResponse } from './base-http'
import type { PrerenderManifest } from '../build'

import { byteLength } from './api-utils/web'
import BaseServer, {
Expand All @@ -23,7 +24,6 @@ import { isDynamicRoute } from '../shared/lib/router/utils'
import { interpolateDynamicPath, normalizeVercelUrl } from './server-utils'
import { getNamedRouteRegex } from '../shared/lib/router/utils/route-regex'
import { IncrementalCache } from './lib/incremental-cache'
import { PrerenderManifest } from '../build'

interface WebServerOptions extends Options {
webServerConfig: {
Expand Down

0 comments on commit b566fac

Please sign in to comment.