Skip to content

Commit

Permalink
Merge branch 'canary' into img/default-loader-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Oct 25, 2020
2 parents 8873107 + 6d3b065 commit af5204b
Show file tree
Hide file tree
Showing 20 changed files with 63 additions and 27 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Expand Up @@ -17,5 +17,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "9.5.6-canary.13"
"version": "9.5.6-canary.14"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "9.5.6-canary.13",
"version": "9.5.6-canary.14",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "9.5.6-canary.13",
"version": "9.5.6-canary.14",
"description": "ESLint plugin for NextJS.",
"main": "lib/index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "9.5.6-canary.13",
"version": "9.5.6-canary.14",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "9.5.6-canary.13",
"version": "9.5.6-canary.14",
"license": "MIT",
"dependencies": {
"chalk": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "9.5.6-canary.13",
"version": "9.5.6-canary.14",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "9.5.6-canary.13",
"version": "9.5.6-canary.14",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-google-analytics/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-google-analytics",
"version": "9.5.6-canary.13",
"version": "9.5.6-canary.14",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-google-analytics"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-sentry/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-sentry",
"version": "9.5.6-canary.13",
"version": "9.5.6-canary.14",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-sentry"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "9.5.6-canary.13",
"version": "9.5.6-canary.14",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "9.5.6-canary.13",
"version": "9.5.6-canary.14",
"description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)",
"main": "dist/polyfill-module.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-nomodule/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "9.5.6-canary.13",
"version": "9.5.6-canary.14",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
14 changes: 11 additions & 3 deletions packages/next/next-server/server/next-server.ts
Expand Up @@ -1183,8 +1183,10 @@ export default class Server {
{ components, query }: FindComponentsResult,
opts: RenderOptsPartial
): Promise<string | null> {
const is404Page = pathname === '/404'

// we need to ensure the status code if /404 is visited directly
if (pathname === '/404') {
if (is404Page) {
res.statusCode = 404
}

Expand Down Expand Up @@ -1255,13 +1257,19 @@ export default class Server {
urlPathname = stripNextDataPath(urlPathname)
}

const ssgCacheKey =
let ssgCacheKey =
isPreviewMode || !isSSG
? undefined // Preview mode bypasses the cache
: `${locale ? `/${locale}` : ''}${resolvedUrlPathname}${
query.amp ? '.amp' : ''
}`

if (is404Page && isSSG) {
ssgCacheKey = `${locale ? `/${locale}` : ''}${pathname}${
query.amp ? '.amp' : ''
}`
}

// Complete the response with cached data if its present
const cachedData = ssgCacheKey
? await this.incrementalCache.get(ssgCacheKey)
Expand Down Expand Up @@ -1307,7 +1315,7 @@ export default class Server {

// If we're here, that means data is missing or it's stale.
const maybeCoalesceInvoke = ssgCacheKey
? (fn: any) => withCoalescedInvoke(fn).bind(null, ssgCacheKey, [])
? (fn: any) => withCoalescedInvoke(fn).bind(null, ssgCacheKey!, [])
: (fn: any) => async () => {
const value = await fn()
return { isOrigin: true, value }
Expand Down
6 changes: 6 additions & 0 deletions packages/next/next-server/server/render.tsx
Expand Up @@ -637,6 +637,12 @@ export async function renderToHTML(
}

if (data.unstable_notFound) {
if (pathname === '/404') {
throw new Error(
`The /404 page can not return unstable_notFound in "getStaticProps", please remove it to continue!`
)
}

;(renderOpts as any).ssgNotFound = true
;(renderOpts as any).revalidate = false
return null
Expand Down
14 changes: 7 additions & 7 deletions packages/next/package.json
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "9.5.6-canary.13",
"version": "9.5.6-canary.14",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -79,10 +79,10 @@
"@babel/runtime": "7.11.2",
"@babel/types": "7.11.5",
"@hapi/accept": "5.0.1",
"@next/env": "9.5.6-canary.13",
"@next/polyfill-module": "9.5.6-canary.13",
"@next/react-dev-overlay": "9.5.6-canary.13",
"@next/react-refresh-utils": "9.5.6-canary.13",
"@next/env": "9.5.6-canary.14",
"@next/polyfill-module": "9.5.6-canary.14",
"@next/react-dev-overlay": "9.5.6-canary.14",
"@next/react-refresh-utils": "9.5.6-canary.14",
"ast-types": "0.13.2",
"babel-plugin-transform-define": "2.0.0",
"babel-plugin-transform-react-remove-prop-types": "0.4.24",
Expand Down Expand Up @@ -114,7 +114,7 @@
"stream-browserify": "3.0.0",
"style-loader": "1.2.1",
"styled-jsx": "3.3.1",
"use-subscription": "1.4.1",
"use-subscription": "1.5.0",
"vm-browserify": "1.1.2",
"watchpack": "2.0.0-beta.13",
"web-vitals": "0.2.4",
Expand All @@ -129,7 +129,7 @@
"sharp": "0.26.2"
},
"devDependencies": {
"@next/polyfill-nomodule": "9.5.6-canary.13",
"@next/polyfill-nomodule": "9.5.6-canary.14",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
"@taskr/watch": "1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dev-overlay/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/react-dev-overlay",
"version": "9.5.6-canary.13",
"version": "9.5.6-canary.14",
"description": "A development-only overlay for developing React applications.",
"repository": {
"url": "vercel/next.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-refresh-utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/react-refresh-utils",
"version": "9.5.6-canary.13",
"version": "9.5.6-canary.14",
"description": "An experimental package providing utilities for React Refresh.",
"repository": {
"url": "vercel/next.js",
Expand Down
16 changes: 16 additions & 0 deletions test/integration/i18n-support/pages/404.js
@@ -0,0 +1,16 @@
export default function NotFound(props) {
return (
<>
<h1 id="not-found">This page could not be found | 404</h1>
<p id="prop">{JSON.stringify(props)}</p>
</>
)
}

export const getStaticProps = () => {
return {
props: {
is404: true,
},
}
}
5 changes: 5 additions & 0 deletions test/integration/i18n-support/test/index.test.js
Expand Up @@ -79,6 +79,11 @@ function runTests(isDev) {
initialRevalidateSeconds: false,
srcRoute: null,
},
'/404': {
dataRoute: `/_next/data/${buildId}/404.json`,
initialRevalidateSeconds: false,
srcRoute: null,
},
'/en-US/gsp/fallback/first': {
dataRoute: `/_next/data/${buildId}/en-US/gsp/fallback/first.json`,
initialRevalidateSeconds: false,
Expand Down
7 changes: 4 additions & 3 deletions yarn.lock
Expand Up @@ -16753,9 +16753,10 @@ url@^0.11.0:
punycode "1.3.2"
querystring "0.2.0"

use-subscription@1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/use-subscription/-/use-subscription-1.4.1.tgz#edcbcc220f1adb2dd4fa0b2f61b6cc308e620069"
use-subscription@1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/use-subscription/-/use-subscription-1.5.0.tgz#0df66fdf97b9a340147ad72f76fac1db6f56d240"
integrity sha512-/FVRiB2I7NDjzWoNBYPt6YkkvleMm/lFtxj1hH6nX2TVrJ/5UTbovw9OE1efv2Zl0HoAYuTjM7zHd9OsABn5sg==
dependencies:
object-assign "^4.1.1"

Expand Down

0 comments on commit af5204b

Please sign in to comment.