status
stringclasses
1 value
repo_name
stringclasses
13 values
repo_url
stringclasses
13 values
issue_id
int64
1
104k
updated_files
stringlengths
11
1.76k
title
stringlengths
4
369
body
stringlengths
0
254k
issue_url
stringlengths
38
55
pull_url
stringlengths
38
53
before_fix_sha
stringlengths
40
40
after_fix_sha
stringlengths
40
40
report_datetime
unknown
language
stringclasses
5 values
commit_datetime
unknown
closed
vercel/next.js
https://github.com/vercel/next.js
33,860
["packages/next/server/image-optimizer.ts"]
"ENOENT: no such file or directory" - next.js crashes, related to image caching?
### Run `next info` (available from version 12.0.8 and up) ``` root@1d90163fc150:/app# npx --no-install next info /bin/sh: 1: pnpm: not found Operating System: Platform: linux Arch: x64 Version: #1 SMP Debian 4.19.171-2 (2021-01-30) Binaries: Node: 17.4.0 npm: 8.3.1 Yarn: 1.22.17 pnpm: N/A Relevant packages: next: 12.0.10 react: 17.0.2 react-dom: 17.0.2 ``` ### What version of Next.js are you using? 12.0.10 ### What version of Node.js are you using? 17.4.0 ### What browser are you using? Chrome ### What operating system are you using? Debian ### How are you deploying your application? next build ### Describe the Bug Upgraded my site to next.js 12.0.10 and with the new release started getting errors; ``` today at 2:27:38 PMready - started server on 0.0.0.0:3000, url: http://localhost:3000 today at 2:27:38 PMinfo - Loaded env from /app/.env.production today at 2:27:38 PMinfo - Loaded env from /app/.env today at 2:27:39 PMwarn - SWC minify beta enabled. https://nextjs.org/docs/messages/swc-minify-enabled today at 2:37:32 PMError: ENOENT: no such file or directory, open '/app/.next/cache/images/iLU6LIXA6TCl8SepFjJ5LNbyzLiOqZ7U49T1Ftm+jW4=/0.1643714865404.blKDVxGlp5+pf7TBeZBnD7i-BF2A5hQCHH0jGL--cVU=.avif' ``` and then next server dies and restarts ### Expected Behavior shouldn't be crashing. ### To Reproduce any code with avif + image caching support i guess
https://github.com/vercel/next.js/issues/33860
https://github.com/vercel/next.js/pull/33883
aae0370d63bb8f39ad0eace63e0c50897960d4bc
e3e62aa78673f8819583f56eb43c5cc9b4b9dd78
"2022-02-01T11:46:51Z"
javascript
"2022-02-02T21:27:56Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,856
["packages/eslint-plugin-next/lib/rules/link-passhref.js", "test/unit/eslint-plugin-next/link-passhref.test.ts"]
eslint rule link-passhref does not work
### Run `next info` (available from version 12.0.8 and up) _No response_ ### What version of Next.js are you using? 12.0.9 ### What version of Node.js are you using? 16 ### What browser are you using? chrome ### What operating system are you using? macOS ### How are you deploying your application? next start ### Describe the Bug eslint rule `link-passhref` which is part of `next/recommended` does not work as expected. consider the following example: ``` import NextLink from 'next/link' export const Home = () => ( <NextLink href="/test"> <StyledLink>Test</StyledLink> </NextLink> ) ``` According to the rule it should be able to catch this error ### Expected Behavior eslint should show an error ### To Reproduce Use the example from describtiondescription
https://github.com/vercel/next.js/issues/33856
https://github.com/vercel/next.js/pull/33857
3e60c232a86d2c3b40a45a427f1d32a85b89daf7
a7793c7a0c5c5e4496594a3010152cfba31920de
"2022-02-01T10:42:47Z"
javascript
"2022-02-01T18:53:55Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,854
[".github/workflows/build_test_deploy.yml", "packages/next-swc/.cargo/config.toml", "packages/next-swc/crates/napi/npm/android-arm-eabi/README.md", "packages/next-swc/crates/napi/npm/android-arm-eabi/package.json", "packages/next-swc/package.json", "packages/next/package.json", "scripts/install-native.mjs", "yarn.lock"]
"next build" fails in environments with glibc < 2.18
### Run `next info` (available from version 12.0.8 and up) ``` Operating System: Platform: linux Arch: x64 Version: #1 SMP Sat Jul 3 21:51:47 UTC 2021 Binaries: Node: 16.13.2 npm: 8.1.2 Yarn: 1.22.17 pnpm: N/A Relevant packages: next: 12.0.10-canary.2 react: 17.0.2 react-dom: 17.0.2 ``` ### What version of Next.js are you using? 12.0.10 ### What version of Node.js are you using? 16.13.2 ### What browser are you using? none ### What operating system are you using? Linux (Docker image based on CentOS 7) ### How are you deploying your application? Other ### Describe the Bug When I run `next build`, I get the error ``"/lib64/libc.so.6: version `GLIBC_2.18' not found"`` and cannot build. It seems to have been fixed in swc (https://github.com/swc-project/swc/pull/3314), so I would like to see it taken into the `@next/swc` package if possible. ``` $ # yarn run build yarn run v1.22.17 $ next build Attention: Next.js now collects completely anonymous telemetry regarding usage. This information is used to shape Next.js' roadmap and prioritize features. You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL: https://nextjs.org/telemetry info - Checking validity of types info - Attempted to load @next/swc-linux-x64-gnu, but an error occurred: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /src/app/node_modules/@next/swc-linux-x64-gnu/next-swc.linux-x64-gnu.node) info - Attempted to load @next/swc-linux-x64-gnux32, but it was not installed info - Attempted to load @next/swc-linux-x64-musl, but an error occurred: libc.musl-x86_64.so.1: cannot open shared object file: No such file or directory error - Failed to load SWC binary for linux/x64, see more info here: https://nextjs.org/docs/messages/failed-loading-swc error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. ``` ``` $ cat /etc/redhat-release CentOS Linux release 7.9.2009 (Core) $ yum list installed | grep glibc glibc.x86_64 2.17-325.el7_9 @updates glibc-common.x86_64 2.17-325.el7_9 @updates glibc-devel.x86_64 2.17-325.el7_9 @updates glibc-headers.x86_64 2.17-325.el7_9 @updates ``` ### Expected Behavior Execution of `next build` succeeds even if GLIBC < 2.18. ### To Reproduce Run `next build` on CentOS 7 Docker image in host OS ``` $ docker pull centos:7 $ docker run --rm -it centos:7 /bin/bash ``` in docker ``` # yum install gcc # yum update # curl -fsSL https://rpm.nodesource.com/setup_16.x | bash - # yum install -y nodejs # npx create-next-app@latest --typescript # npm run build ```
https://github.com/vercel/next.js/issues/33854
https://github.com/vercel/next.js/pull/34481
ce76d1712e98d7310385c89ec1917242f7c5111c
924b71ccc16c434005c0f4111e86d658734c0133
"2022-02-01T10:33:25Z"
javascript
"2022-02-18T16:04:43Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,829
["packages/next/export/index.ts", "packages/next/pages/_document.tsx", "packages/next/server/base-server.ts", "packages/next/server/config-shared.ts", "packages/next/server/render.tsx", "packages/next/shared/lib/html-context.ts", "test/e2e/prerender.test.ts", "test/e2e/prerender/pages/large-page-data.js"]
Show warning during build if page is returning a large amount of data
### Describe the feature you'd like to request Following up from https://github.com/vercel/next.js/pull/29956, let's consider adding this for `next build`. ### Describe the solution you'd like A warning is outputted during `next build` similar to local devl. ### Describe alternatives you've considered See thread for context: https://twitter.com/ascorbic/status/1487024158492049408
https://github.com/vercel/next.js/issues/33829
https://github.com/vercel/next.js/pull/37264
5739edc7cf5e9a3ba41054c5c701e8ddbe7607ed
39302141b5ea3a1e9a55af906129a44675337cf9
"2022-01-31T16:24:46Z"
javascript
"2022-05-29T01:39:48Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,809
["package.json", "packages/next/client/image.tsx", "test/integration/image-component/default/pages/_document.js", "test/integration/image-component/default/pages/valid-html-w3c.js", "test/integration/image-component/default/test/index.test.js", "yarn.lock"]
next/image produces invalid HTML according to W3C (again)
### Run `next info` (available from version 12.0.8 and up) Operating System: Platform: linux Arch: x64 Version: #29-Ubuntu SMP Wed Jan 12 17:36:47 UTC 2022 Binaries: Node: 16.13.2 npm: 8.3.2 Yarn: 1.22.15 pnpm: 6.11.0 Relevant packages: next: 12.0.9 react: 17.0.2 react-dom: 17.0.2 ### What version of Next.js are you using? 12.0.9 ### What version of Node.js are you using? 16.13.2 ### What browser are you using? N/A ### What operating system are you using? N/A ### How are you deploying your application? N/A ### Describe the Bug Using `[email protected]` yields no invalid HTML errors on the [W3C Markup Validation Service](https://validator.w3.org/) about `next/image`. After upgrading to `[email protected]`, there is now this kind of error: ```txt Error: Bad value data:image/svg+xml,%3csvg xmlns=%27http://www.w3.org/2000/svg%27 version=%271.1%27 width=%271000%27 height=%271000%27/%3e for attribute src on element img: Illegal character in scheme data: space is not allowed. ``` ![image](https://user-images.githubusercontent.com/25207499/151701974-9545dfdc-b27b-47a4-91db-69cdb0849155.png) There was already an error similar to this one before but that has been fixed: #18850 We might add a new e2e test or CI job to ensure that next produces valid HTML according to W3C, so it's not happening again as it is the case now... ### Expected Behavior No errors. Valid HTML according to W3C. ### To Reproduce 1. `npx create-next-app --example image-component image-app` 2. `cd image-app` 3. `npm run build` 4. `npm run start` 5. Go to `localhost:3000` and copy/paste the HTML in [The W3C Markup Validation Service](https://validator.w3.org/) or use the [ html-w3c-validator CLI](https://github.com/Divlo/html-w3c-validator).
https://github.com/vercel/next.js/issues/33809
https://github.com/vercel/next.js/pull/33825
b00270b1abcabf5ef463553bd868f5b3d233d8ca
e0095faf23797d537a2ce9cbc57235cf9306931c
"2022-01-30T13:38:34Z"
javascript
"2022-02-01T00:13:46Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,754
["docs/testing.md"]
Docs: Misspelling in testing documentation
### What is the improvement or update you wish to see? > Styleheets and images aren't used in the tests but importing them may cause errors, so they will need to be mocked. Create the mock files referenced in the configuration above - fileMock.js and styleMock.js - inside a __mocks__ directory: In Testing documentation in sentence reffered above there is misspelling. ### Is there any context that might help us understand? The first word `Styleheets` is misspelled, it suppose to be `Stylesheets`. ### Does the docs page already exist? Please link to it. https://nextjs.org/docs/testing
https://github.com/vercel/next.js/issues/33754
https://github.com/vercel/next.js/pull/33755
7b2ea487458b56e668523c4a0387ad86b6ad36bd
c2b6d235f2635ae8ea4fa8519f64bcc70830f40d
"2022-01-27T21:57:49Z"
javascript
"2022-01-27T22:12:55Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,696
["packages/next/build/index.ts", "test/production/required-server-files.test.ts"]
Output file tracing - server.js compression false
### Run `next info` (available from version 12.0.8 and up) Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 20.6.0: Tue Oct 12 18:33:42 PDT 2021; root:xnu-7195.141.8~1/RELEASE_X86_64 Binaries: Node: 16.11.0 npm: 8.0.0 Yarn: N/A pnpm: N/A Relevant packages: next: 12.0.8 react: 17.0.2 react-dom: 17.0.2 ### What version of Next.js are you using? 12.0.8 ### What version of Node.js are you using? 16.11.0 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? Docker on Azure ### Describe the Bug We are currently using the automatic copying of traced files from the output standalone (https://nextjs.org/docs/advanced-features/output-file-tracing#automatically-copying-traced-files-experimental). This is working great so far. We are using the generated `server.js` to serve our application. However, we noticed our resources were not being compressed automatically anymore, which was the case when we were still using `next start` before. When I have a look in the `server.js` file which is generated, I noticed that the `compress` configuration option was `false` by default. Is there a way to overwrite this? Wouldn't it be more logical to put `compress` on `true` by default? Server.js contents: ```javascript process.env.NODE_ENV = 'production' process.chdir(__dirname) const NextServer = require('next/dist/server/next-server').default const http = require('http') const path = require('path') let handler const server = http.createServer(async (req, res) => { try { await handler(req, res) } catch (err) { console.error(err) res.statusCode = 500 res.end('internal server error') } }) const currentPort = parseInt(process.env.PORT, 10) || 3000 server.listen(currentPort, err => { if (err) { console.error('Failed to start server', err) process.exit(1) } const addr = server.address() const nextServer = new NextServer({ hostname: 'localhost', port: currentPort, dir: path.join(__dirname), dev: false, conf: { env: {}, webpack: null, webpackDevMiddleware: null, eslint: {ignoreDuringBuilds: false}, typescript: {ignoreBuildErrors: false, tsconfigPath: 'tsconfig.json'}, distDir: './.next', cleanDistDir: true, assetPrefix: '', configOrigin: 'next.config.js', useFileSystemPublicRoutes: true, generateEtags: true, pageExtensions: ['tsx', 'ts', 'jsx', 'js'], target: 'server', poweredByHeader: true, compress: true, analyticsId: '', images: { deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840], imageSizes: [16, 32, 48, 64, 96, 128, 256, 384], path: '/_next/image', loader: 'default', domains: [ 'assets-eu-01.kc-usercontent.com', 'preview-assets-eu-01.kc-usercontent.com', ], disableStaticImages: false, minimumCacheTTL: 60, formats: ['image/webp'], }, devIndicators: { buildActivity: true, buildActivityPosition: 'bottom-right', }, onDemandEntries: {maxInactiveAge: 15000, pagesBufferLength: 2}, amp: {canonicalBase: ''}, basePath: '', sassOptions: {}, trailingSlash: false, i18n: {defaultLocale: 'en', locales: ['en', 'nl']}, productionBrowserSourceMaps: false, optimizeFonts: true, excludeDefaultMomentLocales: true, serverRuntimeConfig: {}, publicRuntimeConfig: {}, reactStrictMode: false, httpAgentOptions: {keepAlive: true}, outputFileTracing: true, staticPageGenerationTimeout: 60, swcMinify: false, experimental: { cpus: 11, sharedPool: true, plugins: false, profiling: false, isrFlushToDisk: true, workerThreads: false, pageEnv: false, optimizeImages: false, optimizeCss: false, scrollRestoration: false, externalDir: false, reactRoot: false, disableOptimizedLoading: false, gzipSize: true, swcFileReading: true, craCompat: false, esmExternals: true, isrMemoryCacheSize: 52428800, concurrentFeatures: false, serverComponents: false, fullySpecified: false, outputFileTracingRoot: '', outputStandalone: true, }, configFileName: 'next.config.js', }, }) handler = nextServer.getRequestHandler() console.log('Listening on port', currentPort) }) ``` ### Expected Behavior I would like an option to overwrite the `compress` configuration, or to have `compress` on `true` by default ### To Reproduce Put this in `next.config.js`: ```javascript experimental: { outputStandalone: true, }, ``` Execute `npm run build`, and check the `server.js` file in `.next/standalone`
https://github.com/vercel/next.js/issues/33696
https://github.com/vercel/next.js/pull/33717
c551a329d53ecb1f4543b71cae9672fb8f40ccc1
0d642f1264b5dd20fe4bacb9470e95877bcaf273
"2022-01-26T14:45:35Z"
javascript
"2022-01-27T02:13:10Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,667
["packages/next/build/webpack-config.ts", "packages/next/build/webpack/plugins/functions-manifest-plugin.ts", "packages/next/build/webpack/plugins/middleware-plugin.ts", "packages/next/shared/lib/constants.ts", "test/integration/react-streaming-and-server-components/test/index.test.js"]
Generate functions-manifest.json
For #31317 and other issues, we can no longer using middleware to host the SSR handler. Instead these routes should be generated as standalone functions, and we should emit a `functions-manifest.json` file to indicate the target function runtime and other information.
https://github.com/vercel/next.js/issues/33667
https://github.com/vercel/next.js/pull/33770
030666b5bf46783ab7d79d53ec2f0a7fc365ed02
5b31c18e76754837fb6732bc1fc56fef9d3b7ad2
"2022-01-25T22:40:21Z"
javascript
"2022-01-31T15:46:04Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,615
["packages/next/build/index.ts", "packages/next/lib/worker.ts"]
Custom build with App getInitialProps hangs
### Run `next info` (available from version 12.0.8 and up) Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 Binaries: Node: 14.18.3 npm: 6.14.15 Yarn: 1.22.10 pnpm: N/A Relevant packages: next: 12.0.8 react: 17.0.2 react-dom: 17.0.2 ### What version of Next.js are you using? 12.0.8 ### What version of Node.js are you using? 14.18.3 ### What browser are you using? N/A ### What operating system are you using? macOS ### How are you deploying your application? next build ### Describe the Bug We have found a bug when using Next 12 with [Gasket](https://gasket.dev). When the custom `_app` uses `getInitialProps`, the process hangs and never finishes. This is reproducable with a very simple custom build script, such as in [this repo](https://github.com/kinetifex/next-12-custom-build-bug). When calling the Next `build` function from a script, the process hangs and never exits. ### Expected Behavior Running a build by executing the `next/dist/build` function from a script completes and exits successfully. ### To Reproduce Clone [this repo](https://github.com/kinetifex/next-12-custom-build-bug), and run the custom build script. ``` git clone [email protected]:kinetifex/next-12-custom-build-bug.git cd next-12-custom-build-bug yarn yarn custom-build ```
https://github.com/vercel/next.js/issues/33615
https://github.com/vercel/next.js/pull/34503
7c103fac7d96f7ebadf03620044f3b2c02c4df48
ab40370ea5b69aa4dd601907eb85d25da1140b6b
"2022-01-24T20:52:06Z"
javascript
"2022-02-18T09:12:56Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,600
["packages/next-swc/Cargo.lock", "packages/next-swc/crates/core/Cargo.toml", "packages/next-swc/crates/napi/Cargo.toml", "packages/next-swc/crates/napi/src/bundle/mod.rs", "packages/next-swc/crates/wasm/Cargo.toml"]
next.js seems to be handling JS closures incorrectly
### Run `next info` (available from version 12.0.8 and up) ``` /bin/sh: pnpm: command not found Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 21.0.1: Tue Sep 14 20:56:24 PDT 2021; root:xnu-8019.30.61~4/RELEASE_ARM64_T6000 Binaries: Node: 17.1.0 npm: 8.1.2 Yarn: 1.22.17 pnpm: N/A Relevant packages: next: 12.0.9-canary.6 react: 17.0.2 react-dom: 17.0.2 ``` ### What version of Next.js are you using? 12.0.8 ### What version of Node.js are you using? v17.1.0 ### What browser are you using? Chrome ### What operating system are you using? MacOS ### How are you deploying your application? next run dev ### Describe the Bug The following code executes differently in my browser than in next.js: ``` const myFunction = () => { for (let j = 0; j <= 3; j++) { for (const _ of []) { } if (j === 1) { console.log("before set timeout, j is:", j) setTimeout(() => { console.log("in timeout: j is", j) }, 50) } } return null } myFunction() ``` In my browser, this code correctly prints: ``` before set timeout, j is: 1 in timeout: j is 1 ``` When I paste this into the top level of index.tsx, run `yarn run dev` and navigate my browser to localhost:3000, I see: ``` before set timeout, j is: 1 in timeout: j is 4 ``` ### Expected Behavior I expected the output to be the same whether in browser console or in next.js. ### To Reproduce 1. Create a new next app with `npx create-next-app my-app` 2. Paste the code into pages/index.js 3. `yarn run dev` and look at the console
https://github.com/vercel/next.js/issues/33600
https://github.com/vercel/next.js/pull/33628
eba64c29a4acd4bd1dfc469c3aec3fd37c6bc372
9dd0399dd832dbb6ead80f80e12135b27cfdfd97
"2022-01-24T08:37:55Z"
javascript
"2022-01-25T09:22:22Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,598
["docs/advanced-features/security-headers.md"]
Improve Content-Security-Policy usage explanation
### What is the improvement or update you wish to see? Can you add content security policy header examples? ### Is there any context that might help us understand? At the moment the docs have ``` { key: 'Content-Security-Policy', value: // Your CSP Policy } ``` Could you give examples of what `// Your CSP Policy` could be? Is it a string, an object, an array? In the Mozilla docs they have: `<meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src https://*; child-src 'none';">` but I'm not sure how to add that to `value: // Your CSP Policy` For my use case I need to specify acceptable origins of our iframes. ### Does the docs page already exist? Please link to it. https://nextjs.org/docs/advanced-features/security-headers
https://github.com/vercel/next.js/issues/33598
https://github.com/vercel/next.js/pull/33833
4f5975ffc49967f49acb7ea595b75723aa1356df
ad79c04d6bfe91cb25f2a85e7b170e75ac769ed4
"2022-01-24T07:02:08Z"
javascript
"2022-01-31T20:30:47Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,578
["packages/next/shared/lib/router/router.ts", "test/integration/i18n-support/pages/index.js", "test/integration/i18n-support/test/index.test.js", "test/integration/middleware/core/pages/api/ok.js", "test/integration/middleware/core/pages/redirects/_middleware.js", "test/integration/middleware/core/pages/redirects/index.js", "test/integration/middleware/core/test/index.test.js", "test/lib/browsers/playwright.ts"]
Middleware doesn't redirect properly with i18n
### Run `next info` (available from version 12.0.8 and up) Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 Binaries: Node: 12.22.9 npm: 6.14.15 Yarn: 1.22.17 pnpm: N/A Relevant packages: next: 12.0.8 react: 17.0.2 react-dom: 17.0.2 ### What version of Next.js are you using? 12.0.8 ### What version of Node.js are you using? 12.22.9 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? Vercel ### Describe the Bug Middleware adds unnecessary locale to the path when redirecting to API thus the path becomes `[locale]/api/...` instead of `/api/...`. ### Expected Behavior Redirect to `/api/...` without locale in the path. ### To Reproduce Repository: [next.js-bug-middleware-locale-redirect](https://github.com/rokinsky/next.js-bug-middleware-locale-redirect) Steps to reproduce the behavior: 1. Go to [http://localhost:3000/nl-nl/posts/a](http://localhost:3000/nl-nl/posts/a) 2. Click on the "to B" link 3. Click on the "to C" link 4. See 404 error and the `/nl-nl/api/hello?callback=/nl-nl/posts/c` path.
https://github.com/vercel/next.js/issues/33578
https://github.com/vercel/next.js/pull/35994
aaa823c3fa0b4d248b7c172c0e017b7645793a06
93678b569bb46df9fad39f9db2b18797872b7c15
"2022-01-23T17:19:45Z"
javascript
"2022-04-11T15:59:07Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,553
["docs/advanced-features/custom-app.md"]
`appContext.router.pathname` using old value after using `router.push` for customized app
### Run `next info` (available from version 12.0.8 and up) ``` PS D:\UserData\Downloads\router-push> next info 'pnpm' is not recognized as an internal or external command, operable program or batch file. Operating System: Platform: win32 Arch: x64 Version: Windows 10 Pro Binaries: Node: 16.13.2 npm: 8.3.0 Yarn: 1.22.15 pnpm: N/A Relevant packages: next: 12.0.8 react: 17.0.2 react-dom: 17.0.2 ``` ### What version of Next.js are you using? 12.0.8 ### What version of Node.js are you using? 16.13.2 ### What browser are you using? Chrome ### What operating system are you using? Windows ### How are you deploying your application? Irrelevant ### Describe the Bug Router path name from `getInitialProps` of the customized app is using the old pathname instead of the new one. The line below will show the unexpected behavior in the browser dev console. https://github.com/RaenonX/bug-router-push-custom-app/blob/2df1c10a3f9d6543a1f781bf7fb1524444b468d0/pages/_app.tsx#L10 ### Expected Behavior > Needs to run `next dev` to start the website first. After clicking on the button `push A` or `push B`, the corresponding pathname should be shown as `/A` for `push A`; `/B` for `push B` in the browser console. ### To Reproduce https://github.com/RaenonX/bug-router-push-custom-app Simply checkout the repository above, run `next dev` and observe the behavior.
https://github.com/vercel/next.js/issues/33553
https://github.com/vercel/next.js/pull/35303
99aea513bfb9721a83feef2812f33819c3ede9ae
7891645d4b64bb4ee775d0a5a38fc58abc1dfa90
"2022-01-22T03:48:57Z"
javascript
"2022-03-15T14:34:49Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,544
["packages/next/build/webpack-config.ts", "packages/next/build/webpack/loaders/next-flight-client-loader.ts", "packages/next/build/webpack/loaders/next-flight-server-loader.ts", "packages/next/build/webpack/plugins/flight-manifest-plugin.ts", "test/integration/react-streaming-and-server-components/app/components/client.client.js", "test/integration/react-streaming-and-server-components/app/components/shared.client.js", "test/integration/react-streaming-and-server-components/app/components/shared.js", "test/integration/react-streaming-and-server-components/app/pages/shared.server.js", "test/integration/react-streaming-and-server-components/test/rsc.js", "yarn.lock"]
RSC: loader improvement & shared components
### Background We have 2 webpack loders to handle the transform of server and client components on both server and client side, to make sure: * server components won't get executed on client side * client components can be SSR’d ### Problem #### Exports Those loaders assume you define components with `export default` by default. Which has limited users' ability to export components more flexibly. #### Shared components And we don't know how the shared components are defined: if a component from a file with js extension is imported and can work well in both server/client components, we call them shared components. Loaders should be able to handle those cases to let shared components behave differently on the 2 sides. Since the import paths could be aliased, the import identifiers could be renamed or assigned dynamically, it's hard to capture it as a shared one or not. This could be tricky.
https://github.com/vercel/next.js/issues/33544
https://github.com/vercel/next.js/pull/34692
175e081e862b503d2daf4c2d07d589f86d037f06
8ba2aec022f88b8d773013c8188fe284779bba8c
"2022-01-21T16:06:05Z"
javascript
"2022-02-28T15:00:28Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,536
["errors/invalid-api-status-body.md"]
API Routes 204 > Conflict between TypeScript and linter rules
### Run `next info` (available from version 12.0.8 and up) Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:24 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T8101 Binaries: Node: 16.13.2 npm: 7.24.2 Yarn: N/A pnpm: N/A Relevant packages: next: 12.0.8 react: 17.0.2 react-dom: 17.0.2 ### What version of Next.js are you using? 12.0.8 ### What version of Node.js are you using? 16.13.2 ### What browser are you using? Edge ### What operating system are you using? macOS 12.0.1 ### How are you deploying your application? localhost ### Describe the Bug In a route API, if I want to return a 204 HTTP Code (No Content), I first added an empty object `{}` as body response, but I get an error inside my terminal : > A body was attempted to be set with a 204 statusCode for /api/hello, this is invalid and the body was ignored. > See more info here https://nextjs.org/docs/messages/invalid-api-status-body So in the docs, we have this code example to use: ```js export default function handler(req, res) { res.status(204).send() } ``` But by using it, it's now a TypeScript which appears in VSC ``` Expected 1 arguments, but got 0.ts(2554) utils.d.ts(217, 25): An argument for 'body' was not provided. ``` ```ts // utils.d.ts:217 /** * Send body of response */ declare type Send<T> = (body: T) => void; ``` I try to change the `res` type with `res: NextApiResponse<any>` but it's not change. And if I use `res: NextApiResponse<void>`, the error disappear for the `204` return, but now is on a `200` or `400` for example. The only solution looks like to force the cast as : ```ts ;(res as NextApiResponse<void>).status(204).send() ``` Is there any solution for casting `body` type depending of the status code? Thanks ### Expected Behavior Allow to use an empty/void parameter in the `send()` method for a 204 API response. ### To Reproduce ```ts // /pages/api/hello.ts import type { NextApiRequest, NextApiResponse } from 'next' export default function handler(req: NextApiRequest, res: NextApiResponse) { res.status(204).send() } ```
https://github.com/vercel/next.js/issues/33536
https://github.com/vercel/next.js/pull/33611
bc223d76e0e1962ba5904b52597c4b3a47184f11
b7725133f867b5e530dd4bb5d1fd8d5d389e3364
"2022-01-21T14:21:02Z"
javascript
"2022-02-03T02:41:28Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,476
["packages/next/shared/lib/loadable.js", "test/production/next/jest/index.test.ts"]
Regression in 12.0.8 for jest: TypeError: require.resolveWeak is not a function
### Run `next info` (available from version 12.0.8 and up) Operating System: Platform: win32 Arch: x64 Version: Windows 10 Enterprise Binaries: Node: 16.8.0 npm: 7.21.0 Yarn: 1.22.10 pnpm: N/A Relevant packages: next: 12.0.8 react: 17.0.2 react-dom: 17.0.2 ### What version of Next.js are you using? 12.0.8 ### What version of Node.js are you using? 16.8.0 ### What browser are you using? Edge (Chromium) ### What operating system are you using? Windows 11 Enterprise (by the way, why does next info say I am using Windows 10??) ### How are you deploying your application? On Azure App Service as docker container ### Describe the Bug We have a Next.js website where the unit tests are using Jest. When I try to upgrade the website from Next.js 12.0.7 to 12.0.8 the unit tests which test code that uses dynamic code loading start failing. It looks to me this is related to this previously closed bug, which would make this a regression for Next.js 12.0.8: [TypeError: require.resolveWeak is not a function (jest test) #19862](https://github.com/vercel/next.js/issues/19862) Example output ``` ● Test suite failed to run TypeError: require.resolveWeak is not a function > 29 | const HeaderSearchBoxMobile = dynamic(() => import('../HeaderSearchBox/HeaderSearchBoxMobile/HeaderSearchBoxMobile')); ``` ### Expected Behavior Tests should pass even if the code they test uses dynamic() ### To Reproduce Run a Jest test where the test code tests some code that uses dynamic() to load some other code.
https://github.com/vercel/next.js/issues/33476
https://github.com/vercel/next.js/pull/33908
694407450638b037673c6d714bfe4126aeded740
40329a70a5b4680e71c5ee1d9a7e59b10d80f113
"2022-01-19T22:13:35Z"
javascript
"2022-02-08T14:02:53Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,463
["packages/next/client/image.tsx", "test/integration/image-component/default/pages/on-loading-complete.js", "test/integration/image-component/default/test/index.test.js"]
onLoadingComplete is being called several times when parent rerenders
### Run `next info` (available from version 12.0.8 and up) _No response_ ### What version of Next.js are you using? 12.0.3 ### What version of Node.js are you using? 14.16.0 ### What browser are you using? Chrome ### What operating system are you using? Windows ### How are you deploying your application? Vercel ### Describe the Bug If a parent rerenders, onLoadingComplete will be called several times, if onLoadingComplete sets a state this might cause an infinite loop. ### Expected Behavior onLoadingComplete should be called only once ### To Reproduce Add an element to an array onLoadingComplete to trigger a re-render cc @styfle
https://github.com/vercel/next.js/issues/33463
https://github.com/vercel/next.js/pull/33474
96057c8f67db41cdb8a1ed831e459d6b1e4e4c01
c879fce0d465cd96d0d05e329c0a8a83f46e29d9
"2022-01-19T14:57:58Z"
javascript
"2022-01-20T15:29:34Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,462
["package.json", "packages/next/compiled/node-fetch/index.js", "yarn.lock"]
Upgrade `node-fetch`
### Run `next info` (available from version 12.0.8 and up) Operating System: Platform: win32 Arch: x64 Version: Windows 10 Pro Binaries: Node: 14.18.2 npm: 6.14.15 Yarn: 1.22.17 pnpm: N/A Relevant packages: next: 12.0.8 react: 17.0.2 react-dom: 17.0.2 ### What version of Next.js are you using? 12.0.8 ### What version of Node.js are you using? 14.18.2 ### What browser are you using? Chrome ### What operating system are you using? Windows 10 ### How are you deploying your application? Vercel ### Describe the Bug Vulnerability in Next.js 12.0.8, in node-fetch package ### Expected Behavior λ snyk test next Testing next... ✗ Medium severity vulnerability found in node-fetch Description: Information Exposure Info: https://snyk.io/vuln/SNYK-JS-NODEFETCH-2342118 Introduced through: [email protected] From: [email protected] Organization: xxx Package manager: npm Open source: yes Project path: next Tested next for known vulnerabilities, found 1 vulnerability, 1 vulnerable path. ### To Reproduce install nextjs project install snyk global run snyk test
https://github.com/vercel/next.js/issues/33462
https://github.com/vercel/next.js/pull/33466
818f6b32583c260dfd4a4cd8dbd4841bd5d4639c
1d4f364515d34586b864923dafb7888bf1ff79d2
"2022-01-19T14:25:54Z"
javascript
"2022-01-19T16:48:11Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,458
["packages/next-swc/Cargo.lock"]
swcMinify: true, spread props triggers child component re-mount
### Run `next info` (available from version 12.0.8 and up) Operating System: Platform: linux Arch: x64 Version: #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 Binaries: Node: 16.10.0 npm: 7.24.0 Yarn: 1.22.5 pnpm: N/A Relevant packages: next: 12.0.9-canary.2 react: 17.0.2 react-dom: 17.0.2 ### What version of Next.js are you using? 12.0.8 and ^12.0.9-canary.2 ### What version of Node.js are you using? 16.10.0 ### What browser are you using? Chrome ### What operating system are you using? Windows ### How are you deploying your application? next start ### Describe the Bug Using spread props on intermediate component causes its child components to be re-mounted on each re-render. To reproduce, 1. Run `yarn build` 2. Run `yarn start` 3. Go to `http://localhost:3000/spread`, change the input, you'll find that every input change will cause a full remount on the input element. **Only happen when** 1. swcMinify: true 2. Using spread operator `{...props}` ### Expected Behavior Should not cause re-mount when using spread props on parent component. ### To Reproduce https://github.com/frendyguo/swcminify-spread-operator-bug
https://github.com/vercel/next.js/issues/33458
https://github.com/vercel/next.js/pull/33485
2fd17ba1f8712b472914a00326f68104b3968633
a54eb376e1afc261c898cb4872cd053fc0fb98d3
"2022-01-19T12:30:50Z"
javascript
"2022-01-20T08:54:56Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,450
["docs/middleware.md"]
Middleware fails in v12.0.8
### Run `next info` (available from version 12.0.8 and up) ```sh Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:54 PST 2021; root:xnu-8019.61.5~1/RELEASE_X86_64 Binaries: Node: 16.13.0 npm: 8.1.0 Yarn: 3.1.0 pnpm: 6.11.0 Relevant packages: next: 12.0.8 react: 17.0.2 react-dom: 17.0.2 ``` ### What version of Next.js are you using? 12.0.8 ### What version of Node.js are you using? 16.13.0 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? next start ### Describe the Bug After upgrading to v12.0.8 yesterday, middleware throws the following error: ```sh error - Error: To use middleware you must provide a `hostname` and `port` to the Next.js Server ``` The setup is pretty straightforward: * I have `basePath` and `assetPrefix` set * `pages/users/_middleware.ts` is the location ### Expected Behavior Should be working as same as in v12.0.7 ### To Reproduce * Create a project * Add `_middleware.ts` file under `pages/users` for example * Navigate to `/users`
https://github.com/vercel/next.js/issues/33450
https://github.com/vercel/next.js/pull/33535
ebe95f442089d33a7660cb02a6427ce64a9d223f
f4c1594a6bd975016e5b8abf03f541afcf4723ad
"2022-01-19T08:12:23Z"
javascript
"2022-01-21T21:37:15Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,441
["packages/next/server/image-optimizer.ts", "test/integration/image-optimizer/test/index.test.js"]
On nonexistent image request, next/image hangs and eventually returns a 504
### Run `next info` (available from version 12.0.8 and up) ``` Operating System: Platform: linux Arch: x64 Version: #51~20.04.1-Ubuntu SMP Fri Jan 7 06:51:40 UTC 2022 Binaries: Node: 16.13.0 npm: 6.14.15 Yarn: 1.22.15 pnpm: 6.11.0 Relevant packages: next: 12.0.9-canary.0 react: 17.0.2 react-dom: 17.0.2 ``` ### What version of Next.js are you using? 12.0.9-canary.0 ### What version of Node.js are you using? 16.13.0 ### What browser are you using? Chrome ### What operating system are you using? Linux ### How are you deploying your application? Local application ### Describe the Bug On nonexistent image request, next/image hangs and eventually returns a `504`. This happens in a local next app and also in our production app. ### Expected Behavior next/image should return a `404` ### To Reproduce Please have a look at this repo where you can find the steps to reproduce: https://github.com/inside/next-image-app
https://github.com/vercel/next.js/issues/33441
https://github.com/vercel/next.js/pull/33719
311f66ead6658d8b12021dcab5f55b97c956fcde
c551a329d53ecb1f4543b71cae9672fb8f40ccc1
"2022-01-18T16:33:56Z"
javascript
"2022-01-27T01:41:57Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,402
["docs/api-reference/next/script.md", "docs/basic-features/script.md"]
Docs: conflict in next/script's onLoad documentation
### What is the improvement or update you wish to see? I'm afraid there's currently a conflict between the two documentation pages on next/script. The [Script Component page says](https://nextjs.org/docs/basic-features/script#executing-code-after-loading-onload) following: > If you are loading a script with either `beforeInteractive` or `afterInteractive` as a loading strategy, you can execute code after it has loaded using the `onLoad` property However, in the [API reference page on `next/script`](https://nextjs.org/docs/api-reference/next/script#onload), under `onLoad`, it says: > Note: `onLoad` can't be used with the `beforeInteractive` loading strategy. As far as I know, the `onLoad` prop for `beforeInteractive` is not currently working and there's [an open issue](https://github.com/vercel/next.js/issues/33191) on that. Either way, the documentation should be in line with the current state of affairs. ### Is there any context that might help us understand? I can see the reason why a separate API documentation page for next/script exists in addition to the guide page on script optimization, but I would hope that any time either of those two are updated, the other would be checked for inconsistencies. The inconsistency was created in #33097. ### Does the docs page already exist? Please link to it. _No response_
https://github.com/vercel/next.js/issues/33402
https://github.com/vercel/next.js/pull/36453
adcd9143fefe37dd367993a2132550e299a92683
ff140a729162cd2bd14f17b4ecbf269f03966f59
"2022-01-17T16:37:15Z"
javascript
"2022-04-25T17:51:35Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,314
["packages/next/lib/is-error.ts", "packages/next/lib/is-serializable-props.ts", "packages/next/shared/lib/is-plain-object.ts"]
Client bundles contain non es5 code
### Run `next info` (available from version 12.0.8 and up) Operating System: Platform: linux Arch: x64 Version: #1 SMP PREEMPT Wed, 05 Jan 2022 16:20:59 +0000 Binaries: Node: 16.7.0 npm: 7.20.3 Yarn: N/A pnpm: N/A Relevant packages: next: 12.0.8 react: 17.0.2 react-dom: 17.0.2 ### What version of Next.js are you using? 12.0.8 ### What version of Node.js are you using? 16.7.0 ### What browser are you using? Chromium, Firefox ### What operating system are you using? Linux ### How are you deploying your application? next start ### Describe the Bug The update to 12.0.8 introduced a regression w.r.t. es5 compatibility. If running the command series given below the following error occurs: ``` ES-Check Error: ---- · erroring file: ./.next/static/chunks/main-1e7421553b9673ee.js · error: SyntaxError: The keyword 'const' is reserved (1:97874) · see the printed err.stack below for context ---- SyntaxError: The keyword 'const' is reserved (1:97874) ``` I think this is related to the changes in #33159 which added a new method `getProperError` to the `ìs-error.js` file. This method is used on the client side in `next/client/index.tsx`. The previously used `isError` function was very simple and es5 compatible. The new method uses the `isPlainObject` method which contains a `const` declaration. I think the root cause is that `dist/lib` isn't transpiled during building. Looking at the [Babel loader regex](https://github.com/vercel/next.js/blob/canary/packages/next/build/webpack-config.ts#L472-L477) only `dist/shared/lib` seems to be transpiled. So moving those files there might be a solution for this problem. ### Expected Behavior The Webpack bundle files contain only es5 compatible JavaScript code. ### To Reproduce - npx create-next-app@latest --typescript - npx next build - npx es-check es5 './.next/static/**/*.js'
https://github.com/vercel/next.js/issues/33314
https://github.com/vercel/next.js/pull/33690
33784f1342487007619ddb02ccef3167d5cd8df7
662fa6362a07caa9185e999983d42715281a61aa
"2022-01-14T14:01:59Z"
javascript
"2022-01-27T17:59:42Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,294
["packages/next/compiled/@vercel/nft/index.js", "packages/next/package.json", "yarn.lock"]
esbuild not working in prod serverless functions
### Run `next info` (available from version 12.0.8 and up) Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:54 PST 2021; root:xnu-8019.61.5~1/RELEASE_X86_64 Binaries: Node: 15.10.0 npm: 7.5.3 Yarn: 1.22.11 pnpm: 5.4.0 Relevant packages: next: 12.0.8 react: 17.0.2 react-dom: 17.0.2 ### What version of Next.js are you using? 12.0.8 ### What version of Node.js are you using? 15.10.0 ### What browser are you using? Edge ### What operating system are you using? macOS ### How are you deploying your application? Vercel ### Describe the Bug importing esbuild in serverless functions doesn't work in production (but does locally) ### Expected Behavior You should be able to import and use esbuild in API functions without any special configuration ### To Reproduce Reproduction repo. https://github.com/brynshanahan/esbuild-repro https://esbuild-repro.vercel.app/ Esbuild is being used to compile the code at the top of this page in getStaticProps successfully and the button calls the API endpoint (that runs the exact same code as the getStaticProps function)
https://github.com/vercel/next.js/issues/33294
https://github.com/vercel/next.js/pull/33548
f5fb18198c37727b4abe6e85b74fc33ea191381d
f81a6a5f0fc3a33a51112d4d3261d431e704b0da
"2022-01-14T05:28:39Z"
javascript
"2022-01-22T00:14:11Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,291
["packages/next-swc/Cargo.lock"]
Using spread props in a `next/head` child causes void elements to be decorated with a `children` prop
### Run `next info` (available from version 12.0.8 and up) Operating System: Platform: win32 Arch: x64 Version: Windows 10 Pro Binaries: Node: 14.18.1 npm: 8.1.3 Yarn: N/A pnpm: N/A Relevant packages: next: 12.0.8 react: 17.0.2 react-dom: 17.0.2 ### What version of Next.js are you using? 12.0.8 ### What version of Node.js are you using? 14.18.1 ### What browser are you using? Microsoft Edge Version 97.0.1072.55 ### What operating system are you using? Windows 11 ### How are you deploying your application? N/A ### Describe the Bug When using spread props (`{ ...props }`) on a child of `next/head`, the element is decorated with a `children` prop set to `[ undefined, false, undefined, undefined ]`. When this occurs on a void element, this causes an unrecoverable build error. ``` Server Error Error: link is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`. ``` This is what ReactDOM is passed, and tries to validate: ``` { tag: 'link', props: { href: '/favicon.svg', sizes: '192x192', rel: 'icon', children: [ undefined, false, undefined, undefined ] } } ``` [In the reproduction](https://github.com/dstaley/next-head-rest/blob/main/pages/index.js#L21), you can see that no `children` prop is being passed to the element. ### Expected Behavior Page builds correctly and renders in the browser. ### To Reproduce [Reproduction Repo](https://github.com/dstaley/next-head-rest) After cloning the repo and installing dependencies, run `npm run dev` and visit `http://localhost:3000` in a browser.
https://github.com/vercel/next.js/issues/33291
https://github.com/vercel/next.js/pull/33342
790db2c2e4786ecc3127ea32263230f342d1dcf7
aaa77dd73f188494ca5db56cd6932bc66ed3cf35
"2022-01-13T23:53:22Z"
javascript
"2022-01-17T14:09:55Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,265
["packages/next-swc/Cargo.lock", "packages/next-swc/crates/core/Cargo.toml", "packages/next-swc/crates/napi/Cargo.toml", "packages/next-swc/crates/wasm/Cargo.toml"]
Video.js crash when SWC Minify is enabled
### Run `next info` (available from version 12.0.8 and up) _No response_ ### What version of Next.js are you using? 12.0.8 ### What version of Node.js are you using? any ### What browser are you using? Chrome 97.0.4692.71 ### What operating system are you using? Windows11 & MacOS 12.1 ### How are you deploying your application? next start ### Describe the Bug Run `next build && next start`, open the demo in any browser. Click the play button, video can not play, and console shows the error: `VIDEOJS: ERROR: TypeError: Cannot read properties of null (reading 'playlistLoader')` ### Expected Behavior Video plays with no errors. ### To Reproduce Repo: https://github.com/cuyl/next-bug-with-swc-minify Link: https://next-bug-with-swc-minify.vercel.app/ Open the link and click the play button, the error shows on the console.
https://github.com/vercel/next.js/issues/33265
https://github.com/vercel/next.js/pull/33427
3220bbaba337089624e535f2bc71623e593e725f
b111ba159a8b4f76e6f40d9d95cffea746bb8a70
"2022-01-13T14:45:55Z"
javascript
"2022-01-19T08:15:45Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,210
["docs/going-to-production.md"]
Docs: Add section about how cache-control headers are set, depending on how your pages fetch data
### What is the improvement or update you wish to see? See this comment: https://github.com/vercel/next.js/issues/33204#issuecomment-1010840976 ### Is there any context that might help us understand? ^ ### Does the docs page already exist? Please link to it. Maybe here: https://nextjs.org/docs/going-to-production#caching and here: https://nextjs.org/docs/api-reference/next.config.js/headers#cache-control
https://github.com/vercel/next.js/issues/33210
https://github.com/vercel/next.js/pull/35336
0a416acdcf2bc16d4a931301e4c192b74c6823ff
86c1bf6d2b74fa9fa2288a73b529956dd4841bcd
"2022-01-12T10:06:39Z"
javascript
"2022-03-16T10:48:45Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,191
["docs/basic-features/script.md"]
next/script does not trigger onLoad callback when used with beforeInteractive strategy
### Run `next info` (available from version 12.0.8 and up) _No response_ ### What version of Next.js are you using? 11.1.2 ### What version of Node.js are you using? 14.15 ### What browser are you using? Chrome ### What operating system are you using? Linux ### How are you deploying your application? next dev ### Describe the Bug According to the [docs](https://nextjs.org/docs/basic-features/script#executing-code-after-loading-onload), `onLoad` callback of `next/script` component can be used either with `beforeInteractive` and `afterInteractive` strategies. But when using with `beforeInteractive` strategy, `onLoad` callback never gets called. ### Expected Behavior Expect `onLoad` callback to be called when loading script with `beforeInteractive` strategy ### To Reproduce Using the same example of the docs, with stripe script: hasLoaded is never set to true and stripe has loaded never gets printed. I get the same behavior in the latest version of next. Here is a minimal reproducible repo: https://github.com/loft-br/before-interactive-on-load-bug ![image](https://user-images.githubusercontent.com/76054805/148971151-303362fe-092f-45f8-ba43-5f0ae7fb999a.png)
https://github.com/vercel/next.js/issues/33191
https://github.com/vercel/next.js/pull/36261
4a8a3d2400a54448b615fbc75cd91ca8cfea256c
44c7fd79994d4515dd47e3c8ac94cb0e9f670027
"2022-01-11T15:31:37Z"
javascript
"2022-04-19T11:50:19Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,135
["packages/next/compiled/nanoid/index.cjs", "packages/next/compiled/postcss-safe-parser/safe-parse.js", "packages/next/compiled/postcss-scss/scss-syntax.js", "packages/next/package.json", "yarn.lock"]
Outdated PostCSS
### Describe the Bug PostCSS is listed as a direct dependency with a pinned version. This makes it impossible for users to use plugins that require a higher version. Context : https://github.com/csstools/postcss-plugins/issues/147 ### Expected PostCSS should be peer dependency with relaxed constraints _having a slightly more flexible issue template would also be nice :D_
https://github.com/vercel/next.js/issues/33135
https://github.com/vercel/next.js/pull/33142
0c5f4e7844e08ae6be7ec3e4f412ecc35c003976
1dd053f9fabaaec460570dca79fe326b3de8dee6
"2022-01-10T11:07:37Z"
javascript
"2022-01-13T16:06:38Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,110
["docs/advanced-features/src-directory.md", "docs/basic-features/environment-variables.md"]
Docs: No info on environment variables in the /src folder
### What is the improvement or update you wish to see? Change this line in [this page](https://nextjs.org/docs/advanced-features/src-directory): > Config files like next.config.js and tsconfig.json should be inside the root directory, moving them to src won't work. Same goes for the public directory To: > Config files like next.config.js and tsconfig.json, as well as environment variables, should be inside the root directory, moving them to src won't work. Same goes for the public directory And add a note [here](https://nextjs.org/docs/basic-features/environment-variables#loading-environment-variables): > Note: If you are using a /src folder, please note that Next.JS will load the .env files **only** from the parent folder and **not** from the /src folder. ### Is there any context that might help us understand? I've had this tiny issue that I didn't think of, but maybe one line in the documentation might help other people as well, since it's a small thing that is [not](https://nextjs.org/docs/advanced-features/src-directory) [mentioned](https://nextjs.org/docs/api-reference/next.config.js/environment-variables): if you, by any chance, have environment variables in your /src folder, they're not gonna be read by the program. If you have them in the parent folder however, they will be read. Maybe it's not the most important problem around, but it would be great if it would be mentioned in the documentation somewhere (if not on both the Environment Variables page as well as the /src folder one). Kind regards ### Does the docs page already exist? Please link to it. https://nextjs.org/docs/basic-features/environment-variables#loading-environment-variables https://nextjs.org/docs/advanced-features/src-directory
https://github.com/vercel/next.js/issues/33110
https://github.com/vercel/next.js/pull/33136
213f5a43eac7c95810ae6ccc49d8d36cedfe6115
8ae08b94d8737cf421c4c07327c594fa17f5c9f2
"2022-01-09T12:42:45Z"
javascript
"2022-01-10T13:58:29Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,081
["packages/next/shared/lib/router/router.ts", "packages/next/shared/lib/router/utils/parse-relative-url.ts", "packages/next/shared/lib/utils.ts", "test/integration/client-navigation/pages/nav/relative-1.js", "test/integration/client-navigation/pages/nav/relative-2.js", "test/integration/client-navigation/pages/nav/relative/index.js", "test/integration/client-navigation/test/index.test.js", "test/unit/parse-relative-url.test.ts"]
next/link treats initial dot incorrectly
### Run `next info` (available from version 12.0.8 and up) Operating System: Platform: Windows Arch: x64 Version: Windows 10 Enterprise Binaries: Node: 16.0.0 npm: 7.10.0 Yarn: N/A pnpm: N/A Relevant packages: next: 12.0.7 react: 17.0.2 react-dom: 17.0.2 ### What version of Next.js are you using? 12.0.7 ### What version of Node.js are you using? 16.0.0 ### What browser are you using? Chrome ### What operating system are you using? Windows 10 ### How are you deploying your application? Only local project for now ### Describe the Bug At a page like https://www.example.com/suburl/ Using standard html syntax to link to a sub path `<Link href="./path/"><a href="./path/">a</a></Link>` next/link sends the user to the wrong url: example.com/path/ - it skips the dot which should be the current path. Seems like it should be supported based on: https://github.com/vercel/next.js/pull/614 ### Expected Behavior The link should lead to: https://www.example.com/suburl/path/ . If you disable js in the browser you get the correct native bahavior of course. ### To Reproduce At a page like https://www.example.com/suburl/ next.config.mjs: /** * @type {import('next').NextConfig} */ const nextConfig = { trailingSlash: true, } export default nextConfig In a component: <Link href="./path/"> <a>link</a> </Link>
https://github.com/vercel/next.js/issues/33081
https://github.com/vercel/next.js/pull/36823
99b017e5cbcc7cc9bd220332f6f4847540a44629
87826ee186fc65c0b3b4288791f4b575158371c9
"2022-01-07T09:24:25Z"
javascript
"2022-05-22T16:43:48Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,076
["docs/advanced-features/using-mdx.md"]
typo in documentation for MDX custom components leads to syntax error: unexpected token
### Run `next info` (available from version 12.0.8 and up) ``` Operating System: Platform: linux Arch: x64 Version: #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 Binaries: Node: 16.13.1 npm: 8.1.2 Yarn: 1.22.10 pnpm: N/A Relevant packages: next: 12.0.8-canary.19 react: 17.0.2 react-dom: 17.0.2 ``` ### What version of Next.js are you using? 12.0.7 or canary ### What version of Node.js are you using? v16.13.1 ### What browser are you using? Firefox ### What operating system are you using? Linux ### How are you deploying your application? testing ### Describe the Bug The [documentation for custom components in MDX](https://nextjs.org/docs/advanced-features/using-mdx#layouts) contains this example: ```js export default = ({ children }) => <MyLayoutComponent meta={meta}>{children}</MyLayoutComponent> ``` The `=` sign here may be a typo. It leads to a syntax error: unexpected token. ### Expected Behavior It should not lead to a syntax error. ### To Reproduce See [this code sandbox](https://codesandbox.io/s/modern-river-kbms2?file=/pages/about.mdx).
https://github.com/vercel/next.js/issues/33076
https://github.com/vercel/next.js/pull/33077
aeb67cc28d1d589719b95043042c6cb8f9aab26c
e5e04c9039fd81f31309514a0502fc0e1af272eb
"2022-01-06T21:30:20Z"
javascript
"2022-01-06T23:32:31Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,043
["packages/next/build/polyfills/process.js", "packages/next/build/webpack-config.ts", "packages/next/build/webpack/plugins/middleware-plugin.ts", "test/production/dependencies-can-use-env-vars-in-middlewares/index.test.ts"]
Packages used in middleware can't read env vars >=12.05
### Run `next info` (available from version 12.0.8 and up) _No response_ ### What version of Next.js are you using? 12.0.5 ### What version of Node.js are you using? 16.3.0 ### What browser are you using? chrome ### What operating system are you using? macOS ### How are you deploying your application? yarn dev ### Describe the Bug Packages used in middleware return undefined for `process.env.*` ### Expected Behavior packages used in middleware should be able to read env vars ### To Reproduce https://github.com/braden-clerk/middleware-bug This repo replicates the bug
https://github.com/vercel/next.js/issues/33043
https://github.com/vercel/next.js/pull/33141
f0ad19aef62c058893ed12956d40b22b5a8794d4
4aa9879dcc947fabcaaae14387198b8aa5c45296
"2022-01-05T20:10:06Z"
javascript
"2022-01-10T18:45:00Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,005
["packages/next/build/swc/options.js", "test/unit/jest-next-swc.test.ts"]
`next/jest` sets `NODE_ENV` to `'production'`
### Run `next info` (available from version 12.0.8 and up) Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:24 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T8101 Binaries: Node: 14.17.6 npm: 8.1.4 Yarn: 1.22.15 pnpm: N/A Relevant packages: next: 12.0.8-canary.17 react: 17.0.2 react-dom: 17.0.2 ### What version of Next.js are you using? 12.0.8-canary.17 ### What version of Node.js are you using? 14.17.6 ### What browser are you using? N/A ### What operating system are you using? macOS 12.0.1 (21A559) ### How are you deploying your application? N/A ### Describe the Bug The `next/jest` preset sets `NODE_ENV` to `'production'`. Users familiar with Jest will expect `NODE_ENV` to be `'test'` when running tests. The documentation says: > Set to `'test'` if it's not already set to something else. In this case, `NODE_ENV` is indeed set to `'test'` initially, but is replaced with `'production'`. I've verified this simply by console logging the environment in the test setup files, and again in a test. I did take a _quick_ look, but wasn't able to identify the cause. This is related to #17032 and #17903. ### Expected Behavior When running tests in Jest, `NODE_ENV` should be `'test'`. ### To Reproduce Create a new app using the Jest example: ```sh npx create-next-app --example with-jest with-jest-app ``` Add the following line to the example test: ```ts // __tests__/index.test.tsx console.log(process.env.NODE_ENV); // production ``` Run: ```sh npm test ```
https://github.com/vercel/next.js/issues/33005
https://github.com/vercel/next.js/pull/33032
ce3a3d8eea92c1968dbfdb09176e3d82ccbf039a
1ee13baf000ab391e6017c68eb4770768a8e7674
"2022-01-04T23:55:46Z"
javascript
"2022-01-05T15:22:22Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,913
[".eslintignore", "packages/next/build/swc/options.js", "test/production/emit-decorator-metadata/app/jsconfig.json", "test/production/emit-decorator-metadata/app/pages/api/[[...params]].js", "test/production/emit-decorator-metadata/app/pages/index.js", "test/production/emit-decorator-metadata/index.test.ts"]
Missing `"decoratorMetadata": true` in swc config causes metadata based libraries to fail.
### What version of Next.js are you using? 12.0.7 ### What version of Node.js are you using? 16.7.0 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? Vercel ### Describe the Bug The flag `"decoratorMetadata": true` is not enabled thus SWC does not emit Typescript decorator metadata which causes libraries like [next-api-decorators](https://next-api-decorators.vercel.app/) and `class-validator` to fail trying to look for metadata like `Reflect.getMetadata("design:type")`. ### Expected Behavior SWC config should be configured to support decorator metadata. At the very least this support should be enabled automatically when tsconfig includes the flag `"emitDecoratorMetadata": true` ### To Reproduce 1. Clone: https://github.com/sannajammeh/decorator-metadata-fail 2. Start the dev server 3. Navigate to /api/something in the browser 4. Watch it fail due to an internal issue in the handler which directly comes from a Reflect.getMetadata call at [this line](https://github.com/storyofams/next-api-decorators/blob/ed21529abc8194f6dabfee1d3fcf187f1dc55993/lib/internals/handler.ts#L70) 5. Remove the _ from `.babelrc_`. 6. Restart the dev server 7. Repeat step 3 and watch it work
https://github.com/vercel/next.js/issues/32913
https://github.com/vercel/next.js/pull/32914
8039c6b2b564a82ee67d4abdaae0771cee5e69b7
e0c7794208dbac6d84ad6723741f896527630f34
"2021-12-31T00:19:01Z"
javascript
"2022-02-06T16:48:09Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,848
["packages/next/server.js"]
Unable to test middleware with Jest
### What version of Next.js are you using? 12.0.7 ### What version of Node.js are you using? 16.13.1 ### What browser are you using? Firefox ### What operating system are you using? Pop!_OS ### How are you deploying your application? Vercel ### Describe the Bug When trying to test `_middleware.js` with Jest, I'm unable to `import { NextResponse } from 'next/server'` without throwing an error `SyntaxError: Unexpected token 'export'` because `next/server` uses `export { NextRequest }` in line 1. ### Expected Behavior I would like to be able to test my `_middleware.js` authentication methodology. ### To Reproduce 1. Create a Next app with the aforementioned versions. 2. Create a `_middleware.js` 3. Create a test for it in Jest. 4. Try to import `NextResponse` from `next/server`. 5. Run tests. 6. Get error.
https://github.com/vercel/next.js/issues/32848
https://github.com/vercel/next.js/pull/35181
9bff48b9d5998455c9c038d7f5834a58bb9f429f
84720697e4f00bd77689153f7cf39421be9b1d25
"2021-12-27T15:35:46Z"
javascript
"2022-03-09T22:50:07Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,774
["packages/next/client/use-intersection.tsx", "test/integration/image-component/default/pages/lazy-noref.js", "test/integration/image-component/default/pages/lazy-withref.js", "test/integration/image-component/default/test/index.test.js"]
Next Image does not work properly when used in a horizontally scrolling container
### What version of Next.js are you using? 12.0.7 ### What version of Node.js are you using? 16.13.0 ### What browser are you using? Chrome (Desktop and Android) ### What operating system are you using? macOS Monterey and Android 12 ### How are you deploying your application? Vercel (broken when developing locally with yarn dev as well) ### Describe the Bug There are two issues present: I am using Next Image inside of a horizontally scrolling container and the `lazyBoundary` prop isn't working + on Android Chrome images will permanently disappear once scrolled away from. Firstly, here is a video screenshot of the network tab in Chrome on desktop. Notice that images do not load until the image is literally in the viewport despite `lazyBoundary` being set to an arbitrarily high value (in this case 9000px). From what I understand from the docs, the syntax is similar to that of the CSS `margin` property. This means that I should be able to specify both a vertical and horizontal value via shorthand (ex: `500px 1000px`), correct? https://user-images.githubusercontent.com/10248395/147284509-c4006eba-7203-4bbb-8f67-fcbcad131a8f.mov Secondly (and way more critically) on Chrome for Android I experience the same `lazyBoundary` issue but also experience images completely disappearing after scrolling away from them and back to them. https://user-images.githubusercontent.com/10248395/147284857-322ab2e0-e101-427b-9aca-235852a2b890.mov This issue is present when deploying to Vercel as well as developing locally. ### Expected Behavior The `lazyBoundary` property to be respected in a horizontal container and for images not to disappear on mobile ### To Reproduce https://github.com/agusterodin/next-image-horizontal-scroll-bug-reproduction Present when running the project via yarn dev AND when deployed to Vercel.
https://github.com/vercel/next.js/issues/32774
https://github.com/vercel/next.js/pull/33933
1ac0fc43fafedcda98710c88ed19b6465ba13672
d4b29db8c725331581185d3198d6a98ce291d203
"2021-12-23T19:37:53Z"
javascript
"2022-02-07T15:46:16Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,772
["docs/api-reference/data-fetching/get-static-paths.md"]
Issue with `asPath` when using `getStaticProps` and redirects
### What version of Next.js are you using? 12.0.7 ### What version of Node.js are you using? 14.17.6 ### What browser are you using? Chrome ### What operating system are you using? Windows ### How are you deploying your application? Verel ### Describe the Bug When using redirects in `next.config.js` and trying to output `router.asPath` in a dynamic route that is using `getStaticProps` and `getStaticPaths`, we are getting a `Warning: Text content did not match. Server: "/test-static/123" Client: "/test-statique/123"` message in the console. This is not an issue when using `getServerSideProps`. ### Expected Behavior There should not be any discrepancy between the server and client markup. Basically, we should get the same result as with `getServerSideProps`. ### To Reproduce ## How to reproduce Clone the example repo: ```bash git clone https://github.com/nbouvrette/next-js-test-aspath ``` Run Next.js ```bash npm run dev # or yarn dev ``` Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. Inspect your page, and make sure to open the `console` tab in your browser to see logs. ### Happy path If you click on the first link. Both SSR and client-side `asPath` matches when using `getServerSideProps` - no error is shown in the logs. ### Issue with `asPath` If you return back, and click on the second link you should see the following error in your console: ```console next-dev.js?3515:32 Warning: Text content did not match. Server: "/test-static/123" Client: "/test-statique/123" at div at TestStatic (webpack-internal:///./pages/test-static/[id].tsx:16:72) at MyApp (webpack-internal:///./pages/_app.tsx:36:27) at StyleRegistry (webpack-internal:///./node_modules/styled-jsx/dist/stylesheet-registry.js:231:34) at ErrorBoundary (webpack-internal:///./node_modules/@next/react-dev-overlay/lib/internal/ErrorBoundary.js:26:47) at ReactDevOverlay (webpack-internal:///./node_modules/@next/react-dev-overlay/lib/internal/ReactDevOverlay.js:90:23) at Container (webpack-internal:///./node_modules/next/dist/client/index.js:356:9) at AppContainer (webpack-internal:///./node_modules/next/dist/client/index.js:795:26) at Root (webpack-internal:///./node_modules/next/dist/client/index.js:916:27) See more info here: https://nextjs.org/docs/messages/react-hydration-error ``` If you do a `view page source` you will see that the SSR markup is `/test-static/123` when in fact it should be using `/test-statique/123` as per the `redirects` configuration in `next.config.js`.
https://github.com/vercel/next.js/issues/32772
https://github.com/vercel/next.js/pull/33401
318664562c311322fc63ae993a12736dfaec5c5f
84cba20ae77527dbfadf470d771f9934c9b7c56a
"2021-12-23T18:32:29Z"
javascript
"2022-05-22T22:52:41Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,727
["packages/next/shared/lib/router/router.ts", "test/integration/middleware/core/pages/rewrites/_middleware.js", "test/integration/middleware/core/pages/rewrites/about-bypass.js", "test/integration/middleware/core/test/index.test.js"]
Allow to opt-out from caching Middleware Preflight
### Describe the feature you'd like to request The client needs to know about all routes that are affected by Middleware in order to check with the server if there is a rewrite or a special response and therefore if it should pre-fetch or not. Currently, when we prefetch, we run what we called a "preflight" request to know about the effects of middleware so that it is not required to run the request synchronously when the user clicks a `Link` which potentially can add navigation latency. While this is generally ok, it is possible that customers allow to customise cookies in the client which might affect a middleware invocation. For example, say that we have a session started with a cookie and a middleware that authenticates a request. Then we have a `Link` to an authenticated page in the viewport. In this case, when we first load we preflight the link to see that the user is indeed correctly authenticated. If we also allow the user to clear the cookie without refreshing and then we click the `Link`, Next.js will attempt to navigate to the link because the preflight response is cached. ### Describe the solution you'd like We should allow an escape hatch to stop caching preflight requests so that we re-validate preflight on navigation. For this we can simply leverage the `Cache-Control` header with a `no-cache` directive, or use a different header specific for this purpose, that would force the client to revalidate the request on navigation. In the events of using that directive, prefetch would still run once and it would only force revalidation on navigation. For the most part, this solution should work without creating any side issues with caching while the default behaviour would remain to be caching by default. We should not confuse this feature with disabling pre-flight. In order to disable pre-flight we must always disable pre-fetch. Those two feature are completely tight as Middleware can invalidate prefetching with rewrites. ### Describe alternatives you've considered As an alternative we can introduce an option directly in `NextResponse` that generates an internal header specifically to disable caching. Or we can also use a different header. Still I think it is cleaner and non-intrusive to use the `Cache-Control` directive as eventually we are simply playing with HTTP.
https://github.com/vercel/next.js/issues/32727
https://github.com/vercel/next.js/pull/32767
4d307716f712e0d4376b203bbbeb5c2054d4fe30
82adaee0cd6d71d8b8307c92115bf032cb6330de
"2021-12-22T11:34:44Z"
javascript
"2022-01-03T18:13:28Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,713
["packages/create-next-app/create-app.ts"]
`yarn create next-app` fails when directory is a workspace
### What version of Next.js are you using? 12.0.7 ### What version of Node.js are you using? 16.13.1 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? next export ### Describe the Bug With the following project structure: ``` . ├── node_modules ├── package.json ├── sites # this is a workspace └── yarn.lock ``` And with the following `package.json`: ```json { "name": "workspace-test", "version": "1.0.0", "private": true, "license": "MIT", "workspaces": [ "sites/*" ] } ``` Running this command fails: ```bash yarn create next-app sites/hello-world ``` With this following output: ``` yarn create v1.22.17 [1/4] 🔍 Resolving packages... [2/4] 🚚 Fetching packages... [3/4] 🔗 Linking dependencies... [4/4] 🔨 Building fresh packages... success Installed "[email protected]" with binaries: - create-next-app [##] 2/2Creating a new Next.js app in /Users/karbi/dev/workspace-test/sites/hello-world. Using yarn. Installing dependencies: - react - react-dom - next yarn add v1.22.17 warning Missing version in workspace at "/Users/karbi/dev/workspace-test/sites/asd", ignoring. warning Missing version in workspace at "/Users/karbi/dev/workspace-test/sites/hello-world", ignoring. error An unexpected error occurred: "Cannot read properties of undefined (reading 'manifest')". info If you think this is a bug, please open a bug report with the information provided in "/Users/karbi/dev/workspace-test/sites/hello-world/yarn-error.log". info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command. ``` ### Expected Behavior I would expect that following command would produce a successful boilerplate without error: ```bash yarn create next-app sites/hello-world ``` Additionally, running the following command works successfully when not targeting a workspace: ```bash yarn create next-app hello-world ``` To note, using `npx` works successfully: ```bash npx create-next-app sites/hello-world ``` ### To Reproduce Clone [this repository](https://github.com/karbica/workspace-test) and run the following command in the project root: ```bash yarn create next-app sites/hello-world ``` <img width="1233" alt="Screen Shot 2021-12-21 at 1 20 09 PM" src="https://user-images.githubusercontent.com/8563742/147000196-d2278207-0c00-4d78-8782-f5032493bc98.png">
https://github.com/vercel/next.js/issues/32713
https://github.com/vercel/next.js/pull/33006
b39e49eca93ba9144f024189e18bada8e8dacd72
5b47639747fd583ccfd83b8f140491707dd14184
"2021-12-21T21:22:52Z"
javascript
"2022-02-06T21:03:35Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,656
["docs/basic-features/eslint.md", "errors/manifest.json", "errors/no-styled-jsx-in-document.md", "packages/eslint-plugin-next/lib/index.js", "packages/eslint-plugin-next/lib/rules/no-styled-jsx-in-document.js", "test/unit/eslint-plugin-next/no-styled-jsx-in-document.test.ts"]
ESLint rule idea: `<style>` is not allowed inside _document.js
### Describe the feature you'd like to request As per the docs: https://nextjs.org/docs/advanced-features/custom-document#caveats styled-jsx is not allowed inside custom `_document.js` and I was getting 500 errors on all SSR pages when deploying a site to production that had a `<style>` tag inside a custom `_document.js`. I think it's a good idea to add an ESLint rule to remind users about this since the error I got did not make it straightforward to figure out the root cause of the issue. ### Describe the solution you'd like Add a new ESLint rule warning about the use of `<style>` tags inside a custom `_document.js` ### Describe alternatives you've considered Maybe prevent the build if a `<style>` tag is detected inside a custom `_document.js`
https://github.com/vercel/next.js/issues/32656
https://github.com/vercel/next.js/pull/32678
2f9e2415e5ab376577858c5d0a8219fef98a1138
11ad65e4458990653184b71f64181408b62b3d64
"2021-12-19T14:18:04Z"
javascript
"2022-05-23T02:32:13Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,650
["packages/next/build/jest/jest.ts"]
Running the dev script concurrently with the Jest test script causes Jest to re-run the tests on page compilation
### What version of Next.js are you using? 12.0.4 ### What version of Node.js are you using? 14.18.2 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? Vercel ### Describe the Bug `jest --watch` re-runs the test suites every time the dev server compiles a page. This bug is present on both the babel and swc versions of the jest config. --- I found out that the Jest watcher is watching the `.next/` folder. It used to ignore dot files and folders but that behaviour was changed last year (https://github.com/facebook/jest/pull/10075). It is now necessary to specify the dot folder in `watchPathIgnorePatterns`. I created a PR with Jest to change the documentation: https://github.com/facebook/jest/pull/12161 ### Expected Behavior I expect Jest in watch mode to only re-run the test suites when source files or test files have changed, not when the dev server writes to `.next/`. ### To Reproduce **Step 1:** Set up a project with any of the Jest configurations (Babel or Swc). The project needs to have several pages to be able to navigate between them. **Step 2:** run `yarn dev` in a terminal. In another terminal, run `yarn test`. The scripts are standard: ```json "scripts": { "dev": "next dev", "test": "jest --watch" } ``` **Step 3:** in the jest terminal, press A to run all tests. *My original case was to add a page and a related test file. But running all tests requires less work to show the same result.* **Step 4:** In the browser, navigate between pages. **Result:** - Each time a page is compiled, you get something like this in the dev server terminal (expected): ```bash wait - compiling /about... event - compiled successfully in 190 ms (221 modules) ``` - At the same time, in the jest terminal, the test suites are re-rerun, in spite of there being no change to the source or test files.
https://github.com/vercel/next.js/issues/32650
https://github.com/vercel/next.js/pull/32659
8b12b174e50209b0c71e3dd588c7a0871fe79598
6ffa2baa4d0392cddc462eb3788b8c9befb42546
"2021-12-19T09:55:32Z"
javascript
"2021-12-19T19:03:54Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,553
["packages/next-swc/Cargo.lock", "packages/next-swc/crates/core/Cargo.toml", "packages/next-swc/crates/core/tests/loader/issue-32553/input.js", "packages/next-swc/crates/core/tests/loader/issue-32553/output.js", "packages/next-swc/crates/napi/Cargo.toml", "packages/next-swc/crates/wasm/Cargo.toml"]
SWC Bug with JSX transpilation -- unterminated string constant
### What version of Next.js are you using? 12 ### What version of Node.js are you using? 14 ### What browser are you using? n/a ### What operating system are you using? MacOS ### How are you deploying your application? N/A ### Describe the Bug I'd just like to surface this SWC bug here. If you're on Next 12, this can easily bit you, leaving you searching in vane for answers in the Next GitHub issues. https://github.com/swc-project/swc/issues/2896 ### Expected Behavior JSX accepts strings with single quotes ### To Reproduce See linked GH issue.
https://github.com/vercel/next.js/issues/32553
https://github.com/vercel/next.js/pull/32566
47cd07bb75cb8c50fda3680d0f13a796b0e5b687
99f9be585b7c4c998763ca61f02718e8cebf4689
"2021-12-15T22:08:31Z"
javascript
"2021-12-16T13:48:03Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,548
["docs/basic-features/data-fetching.md"]
Docs: getServerSideProps redirect object missing basePath
### What is the improvement or update you wish to see? All of the properties of the server-side redirects should be explained. Currently, [the documentation](https://nextjs.org/docs/basic-features/data-fetching#getserversideprops-server-side-rendering) only states that there are `{ destination: string, permanent: boolean }` when it speaks of the shape of the object. ![image](https://user-images.githubusercontent.com/5453518/146247077-b9ef6cd7-ffaa-4b23-91c7-9f61c43060af.png) However, upon digging, I discovered that there _is_ a `basePath` property when the server processes redirects [here](https://github.com/vercel/next.js/blob/59f7676966570093f56ff35fb0d83eb97b394b7b/packages/next/server/base-server.ts#L1899), unless I'm wrong in my reading of your code. If this is true though, that the redirect object in `getServerSideProps` has a `basePath`, could we please get the documentation updated to reflect this? It would be nice to see a breakdown of the properties with any additional context like we do in the next.config docs: https://nextjs.org/docs/api-reference/next.config.js/redirects ### Is there any context that might help us understand? When working on [PR #352 in the gladly-team/next-firebase-auth repo](https://github.com/gladly-team/next-firebase-auth/pull/352), I was asked a question from the maintainer about support for SSR redirects for destinations that are outside the base path of the app. He mentioned that the documentation in the area isn't clear, so I dug into the next repo and discovered the actual behavior is through an undocumented `basePath` property: vercel/next.js@59f7676/packages/next/server/base-server.ts#L1899 ### Does the docs page already exist? Please link to it. https://nextjs.org/docs/basic-features/data-fetching#getserversideprops-server-side-rendering
https://github.com/vercel/next.js/issues/32548
https://github.com/vercel/next.js/pull/32550
04fbc663f9b2637ad7b37da9d302f2240d1d2e68
15ff1a37d9ff027a7c03cd2c0ec0b815f93ca41c
"2021-12-15T18:51:31Z"
javascript
"2021-12-16T08:54:40Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,515
["packages/next/server/render.tsx", "test/integration/react-streaming-and-server-components/test/index.test.js"]
404 renders __NEXT_DATA__ as string to DOM when using RSC after deploy, locally no response
### What version of Next.js are you using? 12.0.8-canary.5 up to 12.0.8-canary.7 ### What version of Node.js are you using? local: 14.8.1 // vercel: 14 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? Vercel ### Describe the Bug When updating to newest canaries, starting by 12.0.8-canary.5, using `serverComponents: true` and `concurrentFeatures: true` the 404 page (default and custom) won't respond without error to the console. When being deployed, the 404 renders, but with the __NEXT_DATA__ json rendered as string to the dom. When deployed, it's looking like: ![image](https://user-images.githubusercontent.com/9445140/146086208-02dc1cc5-d1bf-4489-8158-93e4d75108c2.png) on reproducible url: https://next-rsc-demo-e3pu88wfg-klotzjesse.vercel.app/thisdoesnotexist and console: ![image](https://user-images.githubusercontent.com/9445140/146086311-0bb96b4b-d59e-4acd-925e-7e881e75d457.png) ### Expected Behavior Render in development. And after deployment, without having __NEXT_DATA__ as string in the dom. ### To Reproduce Update to canary 12.0.8-canary.5 up to .7 Activate in next.config.js ``` module.exports = { experimental: { reactRoot: true, concurrentFeatures: true, serverComponents: true, }, } ``` Deploy to Vercel / run `yarn dev` Run into failure Minimal Reproduction: Failure (server): https://next-rsc-demo-e3pu88wfg-klotzjesse.vercel.app/rsc Running (client): https://next-rsc-demo-e3pu88wfg-klotzjesse.vercel.app Repo: https://github.com/KlotzJesse/next-rsc-demo/tree/rsc-fails-render-with-client-error
https://github.com/vercel/next.js/issues/32515
https://github.com/vercel/next.js/pull/33399
6d8923768460c2c70ad76b68d8c206378976d091
41614e52d72f532601dc2d118f4f40dbd1e63907
"2021-12-14T22:03:15Z"
javascript
"2022-01-17T20:27:12Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,513
["packages/next/build/index.ts", "packages/next/server/image-optimizer.ts"]
Using <Image /> component with-docker results in missing image-optimizer
### What example does this report relate to? with-docker ### What version of Next.js are you using? 12.0.8 ### What version of Node.js are you using? latest ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? Docker ### Describe the Bug When using the `<Image />` component in combination with the new standalone feature https://nextjs.org/docs/advanced-features/output-file-tracing results in the `image-optimizer.js` not being part of the copied node_modules and all request to the image produce a 500 error. Curl request to the image URL that is being requested by next.js in the frontend ```curl 'http://localhost:3000/_next/image?url=https%3A%2F%2Fvia.placeholder.com%2F300&w=640&q=75' \ -H 'Connection: keep-alive' \ -H 'Pragma: no-cache' \ -H 'Cache-Control: no-cache' \ -H 'sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="96", "Google Chrome";v="96"' \ -H 'sec-ch-ua-mobile: ?0' \ -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36' \ -H 'sec-ch-ua-platform: "macOS"' \ -H 'Accept: image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8' \ -H 'Sec-Fetch-Site: same-origin' \ -H 'Sec-Fetch-Mode: no-cors' \ -H 'Sec-Fetch-Dest: image' \ -H 'Referer: http://localhost:3000/' \ -H 'Accept-Language: en,en-US;q=0.9,de;q=0.8,nl;q=0.7' \ --compressed ``` result ``` Internal Server Error ``` ``` Error: Cannot find module './image-optimizer' Require stack: - /app/node_modules/next/dist/server/next-server.js - /app/server.js at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15) at Function.Module._load (node:internal/modules/cjs/loader:778:27) at Module.require (node:internal/modules/cjs/loader:999:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.fn (/app/node_modules/next/dist/server/next-server.js:609:49) at Router.execute (/app/node_modules/next/dist/server/router.js:222:48) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Server.run (/app/node_modules/next/dist/server/next-server.js:1135:29) at async Server.handleRequest (/app/node_modules/next/dist/server/next-server.js:325:20) at async Server.<anonymous> (/app/server.js:18:5) { code: 'MODULE_NOT_FOUND', requireStack: [ '/app/node_modules/next/dist/server/next-server.js', '/app/server.js' ] } ``` 1. Build your container: `docker build -t nextjs-docker .`. 1. Run your container: `docker run -p 3000:3000 nextjs-docker`. 1. Connect to running container `docker exec -it $(docker ps -q) ash` 1. Navigate to server directory `cd node_modules/next/dist/server/` 2. List files in server directory `ls 0la` Output from Docker container file system after connecting with missing `image-optimizer.js` ``` /app $ cd node_modules/next/dist/server/ /app/node_modules/next/dist/server $ ls -la total 300 drwxr-xr-x 4 nextjs nodejs 4096 Dec 14 20:47 . drwxr-xr-x 9 nextjs nodejs 4096 Dec 14 20:47 .. -rw-r--r-- 1 nextjs nodejs 3473 Dec 14 20:47 accept-header.js -rw-r--r-- 1 nextjs nodejs 16027 Dec 14 20:47 api-utils.js -rw-r--r-- 1 nextjs nodejs 3185 Dec 14 20:47 config-shared.js -rw-r--r-- 1 nextjs nodejs 544 Dec 14 20:47 config-utils.js -rw-r--r-- 1 nextjs nodejs 24927 Dec 14 20:47 config.js -rw-r--r-- 1 nextjs nodejs 2687 Dec 14 20:47 crypto-utils.js -rw-r--r-- 1 nextjs nodejs 521 Dec 14 20:47 denormalize-page-path.js -rw-r--r-- 1 nextjs nodejs 2750 Dec 14 20:47 font-utils.js -rw-r--r-- 1 nextjs nodejs 599 Dec 14 20:47 get-page-files.js -rw-r--r-- 1 nextjs nodejs 635 Dec 14 20:47 htmlescape.js -rw-r--r-- 1 nextjs nodejs 827 Dec 14 20:47 image-config.js -rw-r--r-- 1 nextjs nodejs 6674 Dec 14 20:47 incremental-cache.js drwxr-xr-x 2 nextjs nodejs 4096 Dec 14 20:47 lib -rw-r--r-- 1 nextjs nodejs 3068 Dec 14 20:47 load-components.js -rw-r--r-- 1 nextjs nodejs 88521 Dec 14 20:47 next-server.js -rw-r--r-- 1 nextjs nodejs 1492 Dec 14 20:47 node-polyfill-fetch.js -rw-r--r-- 1 nextjs nodejs 1260 Dec 14 20:47 normalize-page-path.js -rw-r--r-- 1 nextjs nodejs 454 Dec 14 20:47 optimize-amp.js -rw-r--r-- 1 nextjs nodejs 1055 Dec 14 20:47 render-result.js -rw-r--r-- 1 nextjs nodejs 51710 Dec 14 20:47 render.js -rw-r--r-- 1 nextjs nodejs 705 Dec 14 20:47 request-meta.js -rw-r--r-- 1 nextjs nodejs 3046 Dec 14 20:47 require.js -rw-r--r-- 1 nextjs nodejs 3194 Dec 14 20:47 response-cache.js -rw-r--r-- 1 nextjs nodejs 11495 Dec 14 20:47 router.js -rw-r--r-- 1 nextjs nodejs 2868 Dec 14 20:47 send-payload.js -rw-r--r-- 1 nextjs nodejs 1477 Dec 14 20:47 serve-static.js -rw-r--r-- 1 nextjs nodejs 1102 Dec 14 20:47 utils.js drwxr-xr-x 5 nextjs nodejs 4096 Dec 14 20:47 web ``` ### Expected Behavior `image-optimizer.js` is being part of node_modules when using standalone mode and 200 is returned with the image instead of 500 ### To Reproduce I created a minimal example here https://github.com/chrisdoc/next.js/commit/3d8eb4dbd94b0f61a94d1b8ddb71e4d56709af8e to reproduce that adds one `<Image />` tag with a reference to an external Image.
https://github.com/vercel/next.js/issues/32513
https://github.com/vercel/next.js/pull/32522
3da1f17d5a28662be1a20107a0361ddc44f914c4
5d606ebae42469ebd2c3e2bc4f94266525c59315
"2021-12-14T21:49:11Z"
javascript
"2021-12-15T14:19:16Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,470
["packages/next-swc/Cargo.lock", "packages/next-swc/crates/core/Cargo.toml", "packages/next-swc/crates/core/tests/loader/issue-32553/input.js", "packages/next-swc/crates/core/tests/loader/issue-32553/output.js", "packages/next-swc/crates/napi/Cargo.toml", "packages/next-swc/crates/wasm/Cargo.toml"]
Sourcemaps stop working due to multiline comment + CRLF line endings
### What version of Next.js are you using? Happens in at least 12.0.0, 12.0.7, 12.0.8-canary.5 and 12.0.8-canary.8. ### What version of Node.js are you using? 16.13.1 ### What browser are you using? Chrome ### What operating system are you using? Windows ### How are you deploying your application? next dev ### Describe the Bug When my function has a multiline comment, sourcemaps break. I can't set a breakpoint on the first `console.log` and the variables in "Scope" make no sense: ![image](https://user-images.githubusercontent.com/2467392/145883025-9b949fde-aeaa-4b82-a077-4c66a5911764.png) ### Expected Behavior I expected the same behavior as when the multiline comment is removed, so being able to set a breakpoint on the first `console.log` and the "Scope" looking like this: ![image](https://user-images.githubusercontent.com/2467392/145882788-b6fe9f38-d7bd-4976-99e5-615d361ffc18.png) ### To Reproduce - Clone https://github.com/leroydev/nextjs-sourcemaps (it's a minimal working example, just 1 extra commit on top of `npx create-next-app@latest --ts`) - Execute `yarn` to install the dependencies - Run `yarn dev` to start Next.js in development - Open http://localhost:3000 - Open Chrome DevTools -> CTRL + P -> `LogSomeText.ts` - Set breakpoints inside the function and reload You can see that when you completely remove the multiline comment in `LogSomeText.ts`, you can set a breakpoint on the first `console.log` again and the variables in the scope make sense again.
https://github.com/vercel/next.js/issues/32470
https://github.com/vercel/next.js/pull/32566
47cd07bb75cb8c50fda3680d0f13a796b0e5b687
99f9be585b7c4c998763ca61f02718e8cebf4689
"2021-12-13T20:26:09Z"
javascript
"2021-12-16T13:48:03Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,424
["docs/api-reference/next/server.md"]
Unable to set cookie before redirect
### What version of Next.js are you using? 12.0.7 ### What version of Node.js are you using? 14.18.1 ### What browser are you using? Opera ### What operating system are you using? MacOS ### How are you deploying your application? next start ### Describe the Bug I cannot seem to find a way to set a cookie THEN redirect using NextResponse. I know that i can do this ```javascript return NextResponse.redirect("/to-here").cookie("hello", "world"); ``` But actually things are a bit more complicated, i need to be able to pass the object around. like: ```javascript const res = new NextResponse(null); // passed to another function res.cookie("hello", "world"); // res now has cookie "hello" set // now redirect (but keep the "hello" cookie) return res.redirect("/to-here"); ``` Perhaps i've done something wrong, i cannot see a way to redirect and also modifying the response object how i need it. Is it possible? ### Expected Behavior I feel i should be able to build the response object how i see fit, but cannot seem to do it. I can't even do it manually. ### To Reproduce try running `res.redirect()` and it will complain that it is not a function.
https://github.com/vercel/next.js/issues/32424
https://github.com/vercel/next.js/pull/32542
738a964eade15cf9c633b99f84f273f27888d81e
4f67edd6387bc377786f32899e5649e09f732b67
"2021-12-12T14:25:23Z"
javascript
"2021-12-21T14:12:02Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,417
["examples/with-storybook-styled-jsx-scss/.storybook/preview.js", "packages/next/client/index.tsx", "packages/next/package.json", "yarn.lock"]
4% increase in bundle size from next 11.1.2 to 12.0.7
### What version of Next.js are you using? 12.0.7 ### What version of Node.js are you using? 14.15.1 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? Vercel ### Describe the Bug We have been struggling with our bundle size and put a huge effort into making it as small as possible Going from Next v. 11.1.2 to 12.0.7 means an increase in bundlesize from 127Kb to 132 kb. This is before and after from next build: ``` Page Size First Load JS ├ /_app 0 B 75.8 kB ├ ● /[...slug] (ISR: 3600 Seconds) (122414 ms) 14.1 kB 127 kB ``` We tried enabling and disabling swcMinify in next.config.js without any noticeable difference ``` Page Size First Load JS ├ /_app 0 B 80.6 kB ├ ● /[...slug] (ISR: 3600 Seconds) (123146 ms) 14 kB 132 kB ``` Is this to be expected? ### Expected Behavior Same of less size. Not bigger. ### To Reproduce The difference in percentage would differ from project to project. To reproduce just monitoring bundle "First Load JS" from next build reveals the problem
https://github.com/vercel/next.js/issues/32417
https://github.com/vercel/next.js/pull/32730
b6fb52bbb04f4259b3a6528b7aeaa753c5f3b23f
ec3ca398cbd17a674fe0efe67a2763baf6490324
"2021-12-12T10:40:35Z"
javascript
"2021-12-22T13:38:27Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,360
["packages/next/compiled/webpack/bundle5.js", "packages/next/package.json", "yarn.lock"]
ReferenceError: Cannot access '__WEBPACK_DEFAULT_EXPORT__' before initialization
### What version of Next.js are you using? 12.0.7 ### What version of Node.js are you using? 14.18.1 ### What browser are you using? N/A ### What operating system are you using? macOS, Alpine ### How are you deploying your application? next start ### Describe the Bug A module which imports an es module and throws an exception at the top level has the exception swallowed and a different (vastly less helpful) exception thrown instead. I am pretty confident that this is a webpack bug, but since next vendors webpack, I'm reporting here. ### Expected Behavior When a module throws an exception during initialization, the exception should be passed to the nearest user exception handler, or crash the application. Instead, a different exception is being thrown due to webpack-generated code. ### To Reproduce Create a file `lib/test.ts` like the following; require it from any page (I used an API page, may be relevant); request that page. ```javascript import { z } from "zod"; throw new Error("error"); export default { z }; ``` You will see the following error in the console, without any stack trace: ``` error - ReferenceError: Cannot access '__WEBPACK_DEFAULT_EXPORT__' before initialization ``` Things to note: 1. "zod" could be replaced by any esmodule package. The root cause is that the code generated by webpack uses a dynamic `import` to import the code, causing to to be an async module. 2. Exporting `{ z }` is just so that the import doesn't get tree-shaken-away.
https://github.com/vercel/next.js/issues/32360
https://github.com/vercel/next.js/pull/33831
a7793c7a0c5c5e4496594a3010152cfba31920de
3ba3bb8d6d8f7ac2dfda1c292fa831b9010c599d
"2021-12-10T08:47:42Z"
javascript
"2022-02-01T19:27:31Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,338
["packages/next/server/render.tsx"]
Make missing Document components trigger an error for production builds
### What version of Next.js are you using? 12.05 and above ### What version of Node.js are you using? 14.17.6 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? Other platform ### Describe the Bug When the user is a bot we only want to serve a plain version of the page without any javascript, but since version 12.05 if we do not include NextScript it triggers a 500 Server error. ### Expected Behavior If we do not include NextScript it should render a version without javascripts, since [this PR](https://github.com/vercel/next.js/pull/31505) was merged we can not do it anymore. As far as I knew, requiring NextScripts for dev environments made total sense because it could not work without javascript in the client side, but in production we have cases where we do not want to send any javascript to the user and the page should be a plain html. In the mentioned PR, the production check was removed. ### To Reproduce - Remove NextScript from a custom _document.js - Requesting any page will trigger a 500 error NextScript must be present.
https://github.com/vercel/next.js/issues/32338
https://github.com/vercel/next.js/pull/32345
10d814d31ace05ac00946ab6396df5c57ca54f03
eba9da09eb1d374a0dff5e782b9791bb76759524
"2021-12-09T21:00:33Z"
javascript
"2021-12-13T22:47:34Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,332
["packages/next/build/webpack/loaders/next-middleware-ssr-loader/render.ts", "packages/next/client/index.tsx", "packages/next/client/rsc.ts", "packages/next/rsc.d.ts", "packages/next/rsc.js", "packages/next/server/render.tsx"]
API to refresh the server root with props
To provide a way for client components to re-render the server component root from the client, with updated props, we need a new API `unstable_useRefreshRoot`. It works similar to the "location" thing in the very first RSC demo: ```js // foo.client.js const refresh = unstable_useRefreshRoot() refresh({ ...props }) ``` where `props` is a serializable object. When calling `refresh`, the RSC root will be re-rendered with these additional `props`. Also this API isn't allowed to be used on the server side. As a note, we will need to move the implementation of this API into `ServerRoot` after #30994 lands.
https://github.com/vercel/next.js/issues/32332
https://github.com/vercel/next.js/pull/32342
55d8a14e8a0adfd2ae4e09113076ef33615564ba
6f8cf675d32bc244883113059622a10a7d8dc49a
"2021-12-09T18:32:47Z"
javascript
"2021-12-10T10:22:31Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,312
["packages/next/compiled/escape-string-regexp/index.js", "packages/next/taskfile.js"]
IE11 & Next.js 12 version have syntax error with rewrites in next.config.js
### What example does this report relate to? with rewrites in next.config.js ### What version of Next.js are you using? 12.0.7 ### What version of Node.js are you using? 14.17.0 ### What browser are you using? ie11 ### What operating system are you using? Windows ### How are you deploying your application? next dev, next build, next start ### Describe the Bug Use npx create-next-app@latest (clear project) Add any rewrites https://nextjs.org/docs/api-reference/next.config.js/rewrites ![image](https://user-images.githubusercontent.com/38090158/145378449-5c17f01b-bddc-4c26-90fd-0e74951b69a9.png) Have Syntax Error in ie11 The error appears in version 12 ### Expected Behavior I expected to start without errors in ie11 ### To Reproduce 1) Install: npx create-next-app@latest (clear project) 2) Add any rewrites: https://nextjs.org/docs/api-reference/next.config.js/rewrites ![image](https://user-images.githubusercontent.com/38090158/145378449-5c17f01b-bddc-4c26-90fd-0e74951b69a9.png) 3) Have Syntax Error in ie11
https://github.com/vercel/next.js/issues/32312
https://github.com/vercel/next.js/pull/32310
3ca0ac7f74fb114e2d0453cfcb49bd2e97107bc0
0b1c9ec47dd3ea96f6ce5d2eec1eaa85e8cd97da
"2021-12-09T10:28:13Z"
javascript
"2021-12-09T19:31:53Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,302
["packages/next/shared/lib/router/router.ts", "test/integration/middleware/core/pages/_interface/[...parts].js", "test/integration/middleware/core/pages/interface/_middleware.js", "test/integration/middleware/core/test/index.test.js"]
Middleware rewrites causing router.replace issue
### What version of Next.js are you using? 12.0.7 ### What version of Node.js are you using? 17.0.1 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? Vercel ### Describe the Bug We have a _middleware that rewrites requests on a special domain to "_dashboard/<pathname>". For example, loading "dashboard.localhost:3000/example/page" does a `NextResponse.rewrite('/_dashboard/example/page')`. Under the hood, we have a page at `pages/_dashboard/[...parts].tsx` to handle the request. The issue comes from the main Next.js Container trying to do a `router.replace` with `href` equal to `/_dashboard/[...parts]` and `as` equal to `/example/page`, with the code causing that here: https://github.com/vercel/next.js/blob/d1a1a4c0f7561235394bdb1911f8a1c99ccdd237/packages/next/client/index.tsx#L213 That `router.replace` call runs into an error: https://nextjs.org/docs/messages/incompatible-href-as since the `as` and `href` don't match. ### Expected Behavior I think the Container should call something like `router.replace('/_dashboard/example/page', '/_dashboard/example/page')`, though to be honest, I'm not 100% sure on how the router should work on domains where middleware is rewriting requests. ### To Reproduce Repro: https://github.com/mmmulani/middleware-bug `npm run dev` and then navigating to `http://localhost:3000/test` or `http://dashboard.localhost:3000/test` causes the error to show Create a dynamic page that can be exported and serve it on a different domain using a middleware. FWIW, it seems like this can be worked around by returning `{}` from `getInitialProps` on the page component.
https://github.com/vercel/next.js/issues/32302
https://github.com/vercel/next.js/pull/32534
e75361fd03872b097e817634c049b3185f24cf56
3da1f17d5a28662be1a20107a0361ddc44f914c4
"2021-12-08T20:54:50Z"
javascript
"2021-12-15T13:33:13Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,123
["packages/next/server/next-server.ts", "test/production/typescript-basic.test.ts"]
Breaking API change in types from 12.0.4 to 12.0.5
### What version of Next.js are you using? 12.0.5 ### What version of Node.js are you using? 14.18.1 ### What browser are you using? Not applicable ### What operating system are you using? macOS ### How are you deploying your application? using custom server ### Describe the Bug The update from `12.0.4` to `12.0.5` including a breaking API change when calling the `createServer` function. In 12.0.4 with TypeScript this compiles fine: ``` const app = next({ dir: './src', dev: process.env.NODE_ENV !== 'production', conf: { compress: false, } as NextServerOptions['conf'], quiet: false, }); const requestHandler = app.getRequestHandler(); ``` In version 12.0.5 the above generates the following TypeError: ``` src/index.ts:9:3 - error TS2322: Type '{ compress: false; }' is not assignable to type 'NextConfigComplete'. Type '{ compress: false; }' is missing the following properties from type 'Required<NextConfig>': i18n, eslint, typescr ipt, headers, and 33 more. 9 conf: { ~~~~ ../../node_modules/next/dist/server/next-server.d.ts:34:5 34 conf: NextConfigComplete; ~~~~ The expected type comes from property 'conf' which is declared here on type 'Partial<Options>' Found 1 error. ``` ### Expected Behavior Existing `createServer` configuration would continue to work in patch versions, especially when the release notes say "This upgrade is completely backward-compatible and recommended for all users on versions below 12.0.5. A backport of the patch to Next.js 11 will be available later today." ### To Reproduce 1. `npx create-next-app@latest --typescript` 1. Change version of `next` and `eslint-config-next` in generated `package.json` to 12.0.4 1. Run `yarn` to get the downgraded version 1. Create `server.ts` with following contents import next from 'next'; const app = next({ dir: '.', dev: process.env.NODE_ENV !== 'production', conf: { compress: false, }, quiet: false, }); const requestHandler = app.getRequestHandler(); 1. Execute `yarn run tsc` to check types, there should be no type errors 1. Change version of `next` and `eslint-config-next` in generated `package.json` to 12.0.5 1. Run `yarn` to get the version 12.0.5 1. Execute `yarn run tsc` to check types, receiving the following error server.ts:5:3 - error TS2322: Type '{ compress: false; }' is not assignable to type 'NextConfigComplete'. Type '{ compress: false; }' is missing the following properties from type 'Required<NextConfig>': i18n, eslint, typescript, headers, and 33 more. 5 conf: { ~~~~ node_modules/next/dist/server/next-server.d.ts:34:5 34 conf: NextConfigComplete; ~~~~ The expected type comes from property 'conf' which is declared here on type 'Partial<Options>' Found 1 error. error Command failed with exit code 2.
https://github.com/vercel/next.js/issues/32123
https://github.com/vercel/next.js/pull/32134
c1a1aa4ae2e0ba5d7c4ba023686c29d592c60c87
769d68047bf61cf40f178da08da3c2a98732df7b
"2021-12-04T14:14:14Z"
javascript
"2021-12-04T22:57:54Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,121
["packages/eslint-plugin-next/lib/rules/no-server-import-in-page.js", "test/unit/eslint-plugin-next/no-server-import-in-page.test.ts"]
next/server should not be imported outside of pages/_middleware.js
### What version of Next.js are you using? 12.0.6 ### What version of Node.js are you using? 14.18.2 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? Vercel ### Describe the Bug I have added _middleware.tsx file in /pages/login/_middleware.tsx and it gives error. ### Expected Behavior It should not give any error ### To Reproduce My files _middleware.tsx ```ts import type { NextRequest } from "next/server"; import { NextResponse } from "next/server"; export const middleware = (req: NextRequest) => { const cookie = req.cookies["auth"]; if (cookie) { return NextResponse.redirect("/"); } }; ``` Folder structure <img width="259" alt="Screenshot 2021-12-04 at 7 29 54 PM" src="https://user-images.githubusercontent.com/32234038/144712222-5abbc69c-f61f-42cf-99f9-51a3ddc63f9d.png"> <img width="1123" alt="Screenshot 2021-12-04 at 7 30 06 PM" src="https://user-images.githubusercontent.com/32234038/144712234-4a6b2815-59c0-41ff-b9de-c8b0a47c7d8c.png">
https://github.com/vercel/next.js/issues/32121
https://github.com/vercel/next.js/pull/32139
20814c34f57e2b1eaf420dab10e265fc815b4114
5b4e139ddecb5e8eb37b31c8d7ab691ae0c27747
"2021-12-04T14:00:37Z"
javascript
"2021-12-05T14:41:10Z"
closed
vercel/next.js
https://github.com/vercel/next.js
32,031
["package.json"]
Running test locally always fails
### What version of Next.js are you using? 12.0.4 ### What version of Node.js are you using? 14.18.1 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? yarn test ### Describe the Bug Everytime I try to run the tests I get the error below. I have been running a single test using `node ./node_modules/.bin/jest -- test/development/acceptance/ReactRefreshLogBox.test.ts` and writing `.only` for a single test. ``` ... > Loading browser with http://localhost:58844/ at Object.webdriver [as default] (lib/next-webdriver.ts:58:13) error - ./node_modules/next/dist/client/dev/amp-dev.js TypeError: Cannot read property 'error' of undefined (node:29703) [DEP_WEBPACK_MODULE_ISSUER] DeprecationWarning: Module.issuer: Use new ModuleGraph API (Use `node --trace-deprecation ...` to show where the warning was created) wait - compiling /_error (client and server)... error - ./node_modules/next/dist/client/dev/amp-dev.js TypeError: Cannot read property 'error' of undefined error - Error: Cannot find module '/private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/.next/fallback-build-manifest.json' Require stack: - /private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/server/load-components.js - /private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/build/utils.js - /private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/build/output/store.js - /private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/build/output/index.js - /private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/cli/next-dev.js - /private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/bin/next Error: Cannot find module '/private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/.next/fallback-build-manifest.json' Require stack: - /private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/server/load-components.js - /private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/build/utils.js - /private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/build/output/store.js - /private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/build/output/index.js - /private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/cli/next-dev.js - /private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/bin/next at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15) at Function.mod._resolveFilename (/private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/build/webpack/require-hook.js:171:28) at Function.Module._load (internal/modules/cjs/loader.js:746:27) at Module.require (internal/modules/cjs/loader.js:974:19) at require (internal/modules/cjs/helpers.js:93:18) at Object.loadDefaultErrorComponents (/private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/server/load-components.js:22:24) at DevServer.getFallbackErrorComponents (/private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/server/dev/next-dev-server.js:679:43) at async DevServer.renderErrorToResponse (/private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/server/next-server.js:1730:40) at async pipe.req.req (/private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/server/next-server.js:1670:30) at async DevServer.pipe (/private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/server/next-server.js:1148:25) { code: 'MODULE_NOT_FOUND', requireStack: [ '/private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/server/load-components.js', '/private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/build/utils.js', '/private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/build/output/store.js', '/private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/build/output/index.js', '/private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/cli/next-dev.js', '/private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/bin/next' ] } error - Error: Cannot find module '/private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/.next/fallback-build-manifest.json' Require stack: - /private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/server/load-components.js - /private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/build/utils.js - /private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/build/output/store.js - /private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/build/output/index.js - /private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/cli/next-dev.js - /private/var/folders/md/c2qmk35d0j90c__dm0yn5cgw0000gn/T/next-install-1638432702733/node_modules/next/dist/bin/next console.log browser log: Failed to load resource: the server responded with a status of 500 (Internal Server Error) ... ``` ### Expected Behavior Tests to pass ### To Reproduce > Clone rep > yarn > yarn test or > node ./node_modules/.bin/jest -- test/development/acceptance/ReactRefreshLogBox.test.ts
https://github.com/vercel/next.js/issues/32031
https://github.com/vercel/next.js/pull/32042
31d2184972097741cadcbee534b018fac1cf9de0
b6914198b4f6ddbec39aaeea50b02035e3c0e58f
"2021-12-02T08:20:04Z"
javascript
"2021-12-03T06:02:59Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,993
["packages/next/build/webpack/loaders/next-middleware-ssr-loader/index.ts", "packages/next/server/base-server.ts", "packages/next/server/load-components.ts", "packages/next/server/render.tsx", "test/integration/react-18/test/index.test.js"]
Pages wrapped with React.memo don’t work if concurrentFeatures is enabled
### What version of Next.js are you using? 12.0.4 / 12.0.5-canary.12 ### What version of Node.js are you using? 16.11.0 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? next dev ### Describe the Bug If you enable `experimental.concurrentFeatures` and export a page component wrapped with `React.memo` you hit the following error: > error - Error: Your page must export a `default` component ### Expected Behavior No error, page uses React.memo. ### To Reproduce See https://github.com/davecardwell/nextjs-memo-page-repro for reproduction, or follow the steps below: ```sh yarn create next-app # modify pages/index.js to wrap default export in React.memo() yarn dev # confirm that the page renders yarn add react@beta react-dom@beta # modify next.config.js to set experimental.concurrentFeatures to true yarn dev # confirm that the page does not render and you see the following error in the terminal: # error - Error: Your page must export a `default` component ```
https://github.com/vercel/next.js/issues/31993
https://github.com/vercel/next.js/pull/34526
4ad1c5a2bc3384d0eeaef2d05452748a3a9ae467
ce76d1712e98d7310385c89ec1917242f7c5111c
"2021-12-01T05:38:08Z"
javascript
"2022-02-18T15:25:10Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,911
["packages/next-swc/Cargo.lock", "packages/next-swc/crates/core/Cargo.toml", "packages/next-swc/crates/core/src/next_ssg.rs", "packages/next-swc/crates/core/src/page_config.rs", "packages/next-swc/crates/core/src/shake_exports.rs", "packages/next-swc/crates/core/tests/full/auto-cjs/1/output.js", "packages/next-swc/crates/core/tests/full/example/output.js", "packages/next-swc/crates/napi/Cargo.toml", "packages/next-swc/crates/napi/src/bundle/mod.rs", "packages/next-swc/crates/wasm/Cargo.toml"]
Swipe on ionic menu doesn't works with swcMinify on start
### What version of Next.js are you using? 12.0.4 ### What version of Node.js are you using? 16.13.0 ### What browser are you using? Chrome, Firefox ### What operating system are you using? Windows 11 ### How are you deploying your application? Vercel, next start ### Describe the Bug The swipe gesture of the '@ionic/react' menu only works in dev, when doing build and start stops working and blocks the animation of the menu. swcMinify option was enable in both cases. The toggle button works in both dev and build. Version @ionic/react: "^5.9.1" ### Expected Behavior The swipe gesture should work correctly when doing build and start with the swcMinify option enabled ### To Reproduce https://github.com/Josyto/next-swc-ionic-menu
https://github.com/vercel/next.js/issues/31911
https://github.com/vercel/next.js/pull/33063
320986a2b897bc512c21f7148f4a4c8ce749dcae
87dbd03eb0ca738fbf669e1f03826af6e59b9b27
"2021-11-29T09:11:53Z"
javascript
"2022-01-10T10:37:32Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,855
["packages/next-swc/crates/core/src/next_ssg.rs", "packages/next-swc/crates/core/tests/fixture/ssg/getStaticProps/issue-31855/input.js", "packages/next-swc/crates/core/tests/fixture/ssg/getStaticProps/issue-31855/output.js"]
Exported members that are used in SSR/SSG/ISG page function are undefined on the client (Attempted import error: '..' is not exported from '..' (imported as '..').)
### What version of Next.js are you using? 12.0.8 ### What version of Node.js are you using? 16.13.1 ### What browser are you using? Chrome Version 96 (Official Build) (64-bit) ### What operating system are you using? Ubuntu 20.04 via WSL 2 & Windows 10 ### How are you deploying your application? next start ### Describe the Bug When you export a member that is used in the page function of `getStaticProps`, it will be `undefined` on the client. For example: ```ts // pages/index.tsx export const revalidateInSeconds = 5 * 60; export const getStaticProps: GetStaticProps = async () => { return { props: {}, revalidate: revalidateInSeconds, }; }; // components/TestComponent.tsx import { revalidateInSeconds } from "../pages"; export function TestComponent(): JSX.Element { console.log("revalidateInSeconds: ", revalidateInSeconds); return <p>Test component</p>; } ``` ### Expected Behavior Exported variables shouldn't be `undefined` on the client. ### To Reproduce ## Reproduction repo I created a reproduction repo for this bug: [https://github.com/bennettdams/nextjs-bug-export-undefined](https://github.com/bennettdams/nextjs-bug-export-undefined) 1. `git clone [email protected]:bennettdams/nextjs-bug-export-undefined.git` 2. `npm i` 3. `npm run build` 4. `npm run start` ### OR ## Manual reproduce 1. [Create Next.js app](https://github.com/bennettdams/nextjs-bug-export-undefined/commit/0c812c6fcc7f86a6d49b6c51c94669fc0574b48e): `npx create-next-app@latest --use-npm --ts .` 2. [Add `getStaticProps` and a `const` to export](https://github.com/bennettdams/nextjs-bug-export-undefined/commit/851a9b4e12699c505dc82cc0c587b9abdf3160c6): ```tsx export const revalidateInSeconds = 5 * 60; export const getStaticProps: GetStaticProps = async () => { return { props: {}, revalidate: revalidateInSeconds, }; }; ``` 3. [Add a test component](https://github.com/bennettdams/nextjs-bug-export-undefined/commit/65064110c06af6b6ef20aa08a1e6f49078af45d4) that logs the imported `const` (`revalidateInSeconds`) and use the component on the page: ```tsx // components/TestComponent.tsx import { revalidateInSeconds } from "../pages"; export function TestComponent(): JSX.Element { console.log("revalidateInSeconds: ", revalidateInSeconds); return <p>Test component</p>; } // pages/index.ts ... <main className={styles.main}> <TestComponent /> <h1 className={styles.title}> Welcome to <a href="https://nextjs.org">Next.js!</a> ... ``` 4. Build & start the app: `npm run build` & `npm run start` # Results, looking at the console logs ### Terminal that is used for building: <details> <summary>Click for text!</summary> ``` > next build info - Checking validity of types info - Creating an optimized production build warn - Compiled with warnings ./components/TestComponent.tsx Attempted import error: 'revalidateInSeconds' is not exported from '../pages' (imported as 'revalidateInSeconds'). Import trace for requested module: ./pages/index.tsx info - Collecting page data ``` </details> ![image](https://user-images.githubusercontent.com/29319414/143610743-84ce34ea-8ccd-4791-a30b-d765729306c3.png) ### Browser: ![image](https://user-images.githubusercontent.com/29319414/143609672-ac97e487-9700-4285-b1d0-abd36223a28e.png) --- ## Additional information: - When you run `npm run dev` instead of using the build, you can see that the `console.log` on the server actually has the value, instead of being `undefined`: ![image](https://user-images.githubusercontent.com/29319414/143610000-42fd9e87-2278-42aa-8303-691cc41f3b51.png) Just on the client it is still `undefined`. - I checked this behavior also for Next.js `v11.1.2` - there, it is not happening. The variable has its value on the client as expected.
https://github.com/vercel/next.js/issues/31855
https://github.com/vercel/next.js/pull/36199
44c7fd79994d4515dd47e3c8ac94cb0e9f670027
deb82802a4d112079ca6fcaa4bca4054d25cec3b
"2021-11-26T16:44:50Z"
javascript
"2022-04-19T12:13:57Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,827
["packages/next/build/webpack-config.ts", "test/integration/middleware/hmr/node_modules/shared-package/index.js", "test/integration/middleware/hmr/node_modules/shared-package/package.json", "test/integration/middleware/hmr/pages/about/_middleware.js", "test/integration/middleware/hmr/pages/index.js"]
Fast refresh not working properly due to page reload when compiling middleware
### What version of Next.js are you using? 12.0.4 ### What version of Node.js are you using? 16.13.0 ### What browser are you using? Chrome, Safari, Edge ### What operating system are you using? macOS ### How are you deploying your application? next dev ### Describe the Bug Since I don't know the technological background or necessity of the page reload for `middleware`, I'm not sure if that's something that you have to live with when working with `middleware` - but any change, like edits made to react components, often trigger a page reload due to the `middleware` being compiled: > wait - compiling /_middleware (middleware only)... This becomes especially frustrating when working with `getStaticProps`. ### Expected Behavior No page reload when applying changes ("Fast Refresh"). ### To Reproduce Basic `middleware` implementation.
https://github.com/vercel/next.js/issues/31827
https://github.com/vercel/next.js/pull/33873
4786557908f000511198e103371e383c1b540150
a803638da2483f0c468522d5da1037657af53e05
"2021-11-26T11:36:49Z"
javascript
"2022-02-01T21:46:07Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,757
["packages/next-swc/.cargo/config.toml", "packages/next-swc/Cargo.lock", "packages/next-swc/crates/core/Cargo.toml", "packages/next-swc/crates/napi/Cargo.toml", "packages/next-swc/crates/wasm/Cargo.toml"]
TS behaviour of break and continue swap after forEach usage
### What version of Next.js are you using? 12.04 ### What version of Node.js are you using? 16.13 ### What browser are you using? Chrome ### What operating system are you using? Window ### How are you deploying your application? yarn dev ### Describe the Bug TS behaviour of "break" and "continue" swap after a "forEach". switching the break/continue around seem to help. but sometime the break break out of both loop. ### Expected Behavior #### Console message 0 x 1 y a message 1 x 2 y a message 2 x 3 y a message 3 x 4 y a message 4 x 5 y a ### To Reproduce #### Code let message = 0; for (let x of [1, 2, 3, 4, 5]) { for (let y of ["a", "b", "c", "d"]) { console.log("Message", ++message, x, y); [].forEach(() => {}); break; } } console.log("WHY", message == 5); #### Console message 0 x 1 y a #### Generate Code var message = 0; var _iteratorNormalCompletion5 = true, _didIteratorError5 = false, _iteratorError5 = undefined; try { var _loop = function(_iterator5, _step5) { var x = _step5.value; var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; try { for(var _iterator = [ "a", "b", "c", "d" ][Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ var y = _step.value; console.log("message", message++, "x", x, "y", y); [].forEach(function() { }); return "break"; } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally{ try { if (!_iteratorNormalCompletion && _iterator.return != null) { _iterator.return(); } } finally{ if (_didIteratorError) { throw _iteratorError; } } } }; for(var _iterator5 = [ 1, 2, 3, 4, 5 ][Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true){ var _ret = _loop(_iterator5, _step5); if (_ret === "break") break; } } catch (err) { _didIteratorError5 = true; _iteratorError5 = err; } finally{ try { if (!_iteratorNormalCompletion5 && _iterator5.return != null) { _iterator5.return(); } } finally{ if (_didIteratorError5) { throw _iteratorError5; } } } console.log("WHY", message == 5);
https://github.com/vercel/next.js/issues/31757
https://github.com/vercel/next.js/pull/31963
85e578a90616ba5ccf809141816045e65284d08c
12b44e279bd0958373c1bc31ba4b9a55f4d3cdbc
"2021-11-24T07:06:27Z"
javascript
"2021-11-30T15:12:37Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,755
["packages/next/lib/helpers/should-use-yarn.ts", "packages/next/lib/install-dependencies.ts"]
`next lint` installs stuff using yarn but there's no `yarn.lock` on my project but it does have a `package-lock.json`
### What version of Next.js are you using? 12.0.5-canary.8 ### What version of Node.js are you using? 16.13.0 ### What browser are you using? Chrome ### What operating system are you using? Windows ### How are you deploying your application? next start ### Describe the Bug `next lint` installs stuff using yarn but there's no `yarn.lock` on my project but it does have a `package-lock.json`. ![image](https://user-images.githubusercontent.com/19225266/143184367-1acb62de-81ac-4e16-8be2-cb49757c2e53.png) ### Expected Behavior Should use NPM instead of Yarn. ### To Reproduce ![image](https://user-images.githubusercontent.com/19225266/143184367-1acb62de-81ac-4e16-8be2-cb49757c2e53.png)
https://github.com/vercel/next.js/issues/31755
https://github.com/vercel/next.js/pull/31926
1aeb230839e5f2578936f6595969c7b608aa190b
2ea2c81f52b74b96f65ba4e2a08e404d31d5205b
"2021-11-24T06:11:21Z"
javascript
"2022-02-05T20:16:25Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,742
["packages/next-swc/crates/core/src/lib.rs", "packages/next-swc/crates/core/src/shake_exports.rs", "packages/next-swc/crates/core/tests/fixture.rs", "packages/next-swc/crates/core/tests/fixture/shake-exports/keep-default/input.js", "packages/next-swc/crates/core/tests/fixture/shake-exports/keep-default/output.js", "packages/next-swc/crates/core/tests/fixture/shake-exports/most-usecases/input.js", "packages/next-swc/crates/core/tests/fixture/shake-exports/most-usecases/output.js", "packages/next-swc/crates/core/tests/full.rs"]
Tree shaking next-swc transformation
### Describe the feature you'd like to request Add an optional next-swc transform to treeshake unused exports
https://github.com/vercel/next.js/issues/31742
https://github.com/vercel/next.js/pull/32253
9c1b183a9cc969f59ab68e0bc6230f6d23b8d79f
0f7f3323c180ebe7046187f3e338a8d818405ea7
"2021-11-23T17:45:02Z"
javascript
"2021-12-08T19:04:13Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,685
["packages/next-swc/crates/napi/src/transform.rs", "packages/next/build/swc/index.js", "packages/next/build/webpack/loaders/next-swc-loader.js"]
Read file source in next-swc when next-swc-loader is used
Currently webpack reads the file and passes the contents to next-swc, we can reduce some overhead by passing the file path to next-swc and then reading/transforming it in next-swc.
https://github.com/vercel/next.js/issues/31685
https://github.com/vercel/next.js/pull/31682
b71f9d9475f0a1790744fe4c9e8d125d50c66f4a
a4159321b20148ff2f9f6fa847395a8c8162dbef
"2021-11-22T12:27:05Z"
javascript
"2021-11-25T14:00:14Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,680
["packages/next/shared/lib/router/router.ts", "test/e2e/middleware-general/app/middleware.js", "test/e2e/middleware-general/app/next.config.js", "test/e2e/middleware-general/app/pages/shallow.js", "test/e2e/middleware-general/test/index.test.ts"]
Unable to disable prefetch on `Router.push()`
### What version of Next.js are you using? 12.0.4 ### What version of Node.js are you using? 16 ### What browser are you using? Chrome ### What operating system are you using? MacOS ### How are you deploying your application? next start ### Describe the Bug Calling `Router.push()` is triggering a prefetch request but the downstream service does not allow HEAD requests and is returning 405. Similar to the `prefetch={false}` prop on the `<Link />` component, would it be possible to disable prefetching when using `Router.push()`? ### Expected Behavior I can disable prefetching on `push()` ### To Reproduce ```ts // Bring in routing functionality from next router hook const { push } = useRouter(); // Create a function to handle logging out through Ory const handleLogOut = useCallback(async () => { const logoutUrl = await axios({ url: `${API_URL}/self-service/logout/browser`, method: "get", headers: { "content-type": "application/json", accept: "application/json", }, withCredentials: true, }); push(logoutUrl.data.logout_url); }, [push]); ```
https://github.com/vercel/next.js/issues/31680
https://github.com/vercel/next.js/pull/37716
bf7bf8217f0d3df37d740a0cebf2f140e9c518b6
7193effcc09f9347f51bd73fac6860c30e4c6acc
"2021-11-22T10:23:17Z"
javascript
"2022-06-15T15:09:13Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,675
["docs/advanced-features/static-html-export.md", "packages/next/build/entries.ts", "packages/next/build/index.ts", "packages/next/build/webpack-config.ts", "packages/next/server/dev/hot-reloader.ts", "test/integration/react-18/app/pages/_document.js"]
500 Error can not use getInitialProps with getStaticProps after updated react 18, next 12
### What version of Next.js are you using? 12.0.4 ### What version of Node.js are you using? 16.13.0 ### What browser are you using? chrome ### What operating system are you using? macOS ### How are you deploying your application? next dev ### Describe the Bug I updated react to version `0.0.0-experimental-149b420f6-20211119` (I heard it as a newest experimantal version, 18) due to use a suspense for my project. (I don't have a plan to use a server component). So I followed all the steps [React 18](https://nextjs.org/docs/advanced-features/react-18) And also I updated next to v12 But I couldn't get a beta version through `npm install next@latest react@beta react-dom@beta` so I tried like this way `npm install react@beta react-dom@beta --save --legacy-peer-deps` And I added a ``` module.exports = { experimental: { concurrentFeatures: true } } ``` Eventually I encountered all this error in every page. `Error: You can not use getInitialProps with getStaticProps. To use SSG, please remove your getInitialProps /` in main page, `Error: 'getInitialProps' in Document component is not supported with 'concurrentFeatures' enabled.` in another pages. I don't use any getInitialProps in my project. ### Expected Behavior I think there could be some error in downloading a react 18 I mentioned. ### To Reproduce ![image](https://user-images.githubusercontent.com/13018853/142820632-5a5058df-bf72-4937-b9ef-730d3a4051a6.png) ![image](https://user-images.githubusercontent.com/13018853/142820702-0f3ef7c9-8d3e-47f1-87ef-78d589e18576.png)
https://github.com/vercel/next.js/issues/31675
https://github.com/vercel/next.js/pull/31954
6e6bd2158ffae0296b08e7c89928844fa9dd32b0
85e578a90616ba5ccf809141816045e65284d08c
"2021-11-22T07:30:23Z"
javascript
"2021-11-30T12:52:14Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,627
["packages/next/build/swc/Cargo.lock", "packages/next/build/swc/crates/core/tests/loader/issue-31627/input.js", "packages/next/build/swc/crates/core/tests/loader/issue-31627/output.js"]
Wrong scope for `this` in functions inside classes with SWC compiler.
### What version of Next.js are you using? 12.0.4 ### What version of Node.js are you using? 16.13.0 ### What browser are you using? Chrome ### What operating system are you using? MacOS ### How are you deploying your application? Irrelevant ### Describe the Bug When turning on SWC for compilation, functions in classes get the wrong `this`. We have a lot of D3-code, where scoped function-`this` is used a lot. Upgrading to Next.js v12 with SWC we get `TypeError: this.querySelectorAll is not a function` from our D3 code. It looks like it only happens when the anonymous functions are contained in a class. When adding a .babelrc to disable SWC, this runs just fine. ### Expected Behavior This code should not crash. ### To Reproduce I produced a minimal repro https://github.com/Jakst/d3-this-next-v12 Here's the relevant code ```javascript import { useEffect } from 'react' import { select, selectAll } from 'd3-selection' export default function Home() { useEffect(() => { new MyClass() }, []) return ( <svg> <g className="group"> <path /> <path /> </g> <g className="group"> <path /> <path /> </g> </svg> ) } class MyClass { constructor() { selectAll('.group').each(function () { select(this).selectAll('path') }) } } ``` Visit a page with that component when SWC compilation is used and the rendering will crash.
https://github.com/vercel/next.js/issues/31627
https://github.com/vercel/next.js/pull/31639
f52211bad39c2a29a7caba40bfeb89b600524b41
3146ed37f83c0ccade1e2c475a04d82b681385ea
"2021-11-19T17:15:02Z"
javascript
"2021-11-20T19:25:52Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,591
["packages/next/build/output/log.ts", "packages/next/server/dev/next-dev-server.ts", "test/integration/custom-server/server.js", "test/integration/custom-server/test/index.test.js", "test/integration/server-side-dev-errors/pages/uncaught-empty-exception.js", "test/integration/server-side-dev-errors/pages/uncaught-empty-rejection.js", "test/integration/server-side-dev-errors/test/index.test.js"]
Next.js don't show stack trace for unhandled rejection errors
### What version of Next.js are you using? 12.0.1 ### What version of Node.js are you using? 16.13.0 ### What browser are you using? Chrome ### What operating system are you using? Windows ### How are you deploying your application? next start ### Describe the Bug ![image](https://user-images.githubusercontent.com/19225266/142496709-f7f40a89-20a7-4853-aca9-b66a77194eb2.png) I can't debug or fix an error that I have no idea where it is. ### Expected Behavior It should show the complete stack trace for errors. ### To Reproduce Trigger an unhandled rejection errors.
https://github.com/vercel/next.js/issues/31591
https://github.com/vercel/next.js/pull/36804
6f344e661723135e48266ac57116cc4b50636475
2e135346cf0847efd85329fb77e86f9e21ad417a
"2021-11-18T21:08:27Z"
javascript
"2022-05-11T17:02:15Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,562
["packages/next-swc/crates/core/src/lib.rs", "packages/next-swc/crates/core/src/styled_jsx/mod.rs", "packages/next-swc/crates/core/src/styled_jsx/transform_css.rs", "packages/next-swc/crates/core/tests/fixture.rs", "packages/next-swc/crates/core/tests/fixture/styled-jsx/issue-31562-interpolation-in-mdea/input.js", "packages/next-swc/crates/core/tests/fixture/styled-jsx/issue-31562-interpolation-in-mdea/output.js", "packages/next-swc/crates/core/tests/full.rs", "packages/next-swc/crates/napi/src/transform.rs", "packages/next-swc/crates/wasm/src/lib.rs"]
@media query interpolation broken in 12.0.4
### What version of Next.js are you using? 12.0.4 ### What version of Node.js are you using? v16.11.0 ### What browser are you using? Chrome ### What operating system are you using? Windows ### How are you deploying your application? next dev ### Describe the Bug PR #31407 fixed #30480 but introduced a new issue where interpolated strings in media queries are sometimes unnecessarily parenthesized. Consider this, which used to work in 12.0.3 and before: ```ts /// theme.ts // Media Queries export const Target: { [size in ScreenSizeQuery]: string } & { [prop in OtherQueries]: string } = { smallOnly: "screen and (max-width: 580px)", smallPlus: "screen and (min-width: 580px)", mediumPlus: "screen and (min-width: 700px)", largePlus: "screen and (min-width: 900px)", xlPlus: "screen and (min-width: 1200px)", touchScreen: "(hover: none), (pointer: coarse)", }; ``` And elsewhere in JSX: ```tsx /// _app.tsx // ... <style jsx global>{` html { font-size: ${Typography.base.size.default}; line-height: ${Typography.base.lineHeight}; } @media ${Target.mediumPlus} { html { font-size: ${Typography.base.size.mediumPlus}; } } @media ${Target.largePlus} { html { font-size: ${Typography.base.size.largePlus}; } } `}</style> // ... ``` ### Expected Behavior This should compile into: ```css html { font-size: 16px; line-height: 1.75; } @media screen and (min-width: 700px) { html { font-size:18px; } } @media screen and (min-width: 900px) { html { font-size:21px; } } ``` ### To Reproduce Instead, in 12.0.4, it compiles into: ```css html {font-size:16px; line-height:1.75} @media (screen and (min-width: 700px)) {html {font-size:18px}} @media (screen and (min-width: 900px)) {html {font-size:21px}} ``` Notably, this should be `@media screen and (min-width: 700px) {}` rather than `@media (screen and (min-width: 700px)) {}`.
https://github.com/vercel/next.js/issues/31562
https://github.com/vercel/next.js/pull/32490
15ff1a37d9ff027a7c03cd2c0ec0b815f93ca41c
47cd07bb75cb8c50fda3680d0f13a796b0e5b687
"2021-11-18T01:36:02Z"
javascript
"2021-12-16T11:23:31Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,536
["packages/next-swc/crates/core/src/next_ssg.rs", "packages/next-swc/crates/core/tests/fixture/ssg/getStaticProps/should-not-remove-import-used-in-render/input.js", "packages/next-swc/crates/core/tests/fixture/ssg/getStaticProps/should-not-remove-import-used-in-render/output.js"]
Unwanted code elimination when using a component in `getStaticProps`
### What version of Next.js are you using? 12.0.4 ### What version of Node.js are you using? v14.15.0 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? - ### Describe the Bug I'm encountering a runtime error, since Next.js seems to be eliminating a component from a function where it is needed. It seems to occur when a component is used both on the page and in `getStaticProps`. ```tsx function PageLayout({children}) { return <div style={{background: 'gray'}}>{children}</div>; } export default function Index() { // ReferenceError: PageLayout is not defined return <PageLayout>Index</PageLayout> } export function getStaticProps() { // When this line is removed, the page no longer breaks console.log(PageLayout.name); return { props: {} }; } ``` <img width="996" alt="Screenshot 2021-11-17 at 16 05 44" src="https://user-images.githubusercontent.com/4038316/142225906-1f10a9c7-7077-44ad-bba4-2eacc53daa9b.png"> Note that the example is intended to be minimal, in my application the usage of the layout component in `getStaticProps` serves a meaningful purpose. In Next.js 11 the above code works flawlessly. ### Expected Behavior No runtime error ### To Reproduce 1. Clone https://github.com/amannn/next-compile-bug 2. Follow the reproduction steps in the README
https://github.com/vercel/next.js/issues/31536
https://github.com/vercel/next.js/pull/32709
5f4947e5a2c75099f7466a6ba8274d8ab4240e6c
600f113358f8074f69682c7199435e30149633a7
"2021-11-17T14:57:45Z"
javascript
"2022-01-11T13:02:24Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,533
["packages/next/server/web/next-url.ts", "test/unit/web-runtime/next-url.test.ts"]
Inconsistent behaviour of `request.nextUrl.href`
### What version of Next.js are you using? 12.0.4 ### What version of Node.js are you using? 16.13.0 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? next start ### Describe the Bug I'm attempting to use Middleware to force a default locale in my application URLs, using [example code from the documentation](https://nextjs.org/docs/advanced-features/i18n-routing#prefixing-the-default-locale). This worked when accessing the application through `localhost`, but when accessing using any other hostname, `request.nextUrl.href` contains the full URL. I'm not sure whether this is expected behaviour, but it seems like it could be a bug as this breaks the example code provided in the documentation. ### Expected Behavior For `request.nextUrl.href` to behave consistently. Either return the full URL, or the application path. Ideally the latter, as the example indicates this would be expected behaviour. ### To Reproduce Take this simple middleware: ```ts import type { NextFetchEvent, NextRequest } from 'next/server' export function middleware(request: NextRequest, event: NextFetchEvent) { return new Response(request.nextUrl.href) } ``` `curl` the app using localhost, see the following: ``` $ curl http://localhost:3000/hello /hello ``` But when using any other IP or hostname: ``` $ curl http://127.0.0.1:3000/hello https://127.0.0.1:3000/hello ```
https://github.com/vercel/next.js/issues/31533
https://github.com/vercel/next.js/pull/31603
9652bdd65393736463f124b9461d8c087562268b
f52211bad39c2a29a7caba40bfeb89b600524b41
"2021-11-17T12:02:44Z"
javascript
"2021-11-19T21:24:22Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,523
["packages/next/server/next-server.ts", "test/integration/middleware/core/pages/rewrites/[param].js", "test/integration/middleware/core/pages/rewrites/_middleware.js", "test/integration/middleware/core/test/index.test.js"]
Middleware NextResponse.rewrite() crashes on colons in paths
### What version of Next.js are you using? 12.0.4 ### What version of Node.js are you using? 16.10.0 ### What browser are you using? Chrome 95 ### What operating system are you using? macOS ### How are you deploying your application? next start ### Describe the Bug Using `NextResponse.rewrite("/:blahblah")` in a middleware to navigate to a path with a colon in it causes an obtuse `TypeError: Expected "blahblah" to be a string` style error(ultimately coming from `path-to-regexp`). ### Expected Behavior Rewriting to a path with a colon in it to simply work without any unexpected replacement being attempted internally. ### To Reproduce something like this in any middleware ```js import { NextResponse } from "next/server"; export default function middleware() { return NextResponse.rewrite("/not-a:param"); } ``` repro repo here: https://github.com/klarstrup/next-middleware-rewrite-bug
https://github.com/vercel/next.js/issues/31523
https://github.com/vercel/next.js/pull/32543
728d82663c9c65b12c22c02de815297c56a3ff53
2c7f8b3d7b098d5f0847662c1b1ee1a10f1efbc1
"2021-11-17T00:05:52Z"
javascript
"2022-03-03T19:36:53Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,513
["examples/with-playwright/styles/Home.module.css"]
Playwright tests do not work on Github CI
### What version of Next.js are you using? 12.0.4 ### What version of Node.js are you using? 14.x ### What browser are you using? Chrome Headless ### What operating system are you using? Ubuntu 18/20 ### How are you deploying your application? Vercel ### Describe the Bug I did several tests this week and couldn't find the reason why nextjs doesn't work with headless on CI. The test code can be found at https://github.com/etc-tiago/demo-nextjs-playwright-github-workflow The start code is https://github.com/vercel/next.js/tree/canary/examples/with-playwright Among the attempts are: - use the `next dev` command to start and test with playwright - use `next build` and `next start` and then start playwright. - use the `next build` command and start `next start` within playwright's web server settings. Apparently there's something with react's hooks. Because the clicks on the button that use the next/router and switch of states are not working. Clicks on <a> links work normally. I did other tests using create-react-app, to validate if it's something related to react or nextjs, and the tests worked. ### Expected Behavior Tests pass when executing actions using hooks, such as useRouter (next/router) during tests with playwright ### To Reproduce The test code can be found at https://github.com/etc-tiago/demo-nextjs-playwright-github-workflow
https://github.com/vercel/next.js/issues/31513
https://github.com/vercel/next.js/pull/36705
cefb944ee5c04396707fca54a731d5458cf4e70b
08ffbc9e09ab9557946631cdfdbb5128e53a5326
"2021-11-16T20:41:49Z"
javascript
"2022-05-05T15:08:28Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,479
["packages/next/build/swc/Cargo.lock"]
Module parse failed: The keyword 'yield' is reserved
### What version of Next.js are you using? 12.0.4 ### What version of Node.js are you using? 16.13.0 ### What browser are you using? NA ### What operating system are you using? macOS ### How are you deploying your application? NA ### Describe the Bug `npm run build` fails with the following error: ``` Module parse failed: The keyword 'yield' is reserved (453:107) File was processed with these loaders: * ./node_modules/next/dist/build/webpack/loaders/next-swc-loader.js You may need an additional loader to handle the result of these loaders. ``` when looked closely at the code, there is an await call which is converted to as yield throwing an error. Not sure why this is throwing as an error. ### Expected Behavior Build should pass. ### To Reproduce Write a function with async/await. Run `npm run build`.
https://github.com/vercel/next.js/issues/31479
https://github.com/vercel/next.js/pull/31540
055e28ef811e7c9e8365c591400c5aac467b1648
2df861ac1285460f18fcd590fe086b85a92f6805
"2021-11-16T05:21:25Z"
javascript
"2021-11-17T16:51:00Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,474
["examples/cms-sanity/lib/queries.js"]
The cms-sanity example throws the following error: Query error: object or function expected.
### What example does this report relate to? cms-sanity ### What version of Next.js are you using? 12.0.4 ### What version of Node.js are you using? 17.1.0 ### What browser are you using? Chrome ### What operating system are you using? Windows ### How are you deploying your application? Vercel ### Describe the Bug With newer API versions, pipe operators at the end of some of the example's GROQ queries returns an error. ``` export const postQuery = ` { "post": *[_type == "post" && slug.current == $slug] | order(_updatedAt desc) | [0] { content, ${postFields} }, "morePosts": *[_type == "post" && slug.current != $slug] | order(date desc, _updatedAt desc) | [0...2] { content, ${postFields} } }` ``` -> Query error: object or function expected ### Expected Behavior Running yarn dev after setting up the example should build the Next app without throwing an error. [This issue thread](https://github.com/sanity-io/GROQ/issues/65#issue-901423589) on the [sanity.io/GROQ](https://github.com/sanity-io/GROQ) repo mentions the error. Sanity's developer [@atombender](https://github.com/atombender) confirms that this error is produced by breaking changes introduced to the GROQ query syntax in the v2021-03-25 API version of Sanity. He also confirms that the changes related to implicit pipe operators were forgotten to be reflected on the version's documentation or changelog. To solve the issue, the [cms-sanity](https://github.com/vercel/next.js/tree/canary/examples/cms-sanity) example's code should be updated by removing the implicit pipe operators between order and the square bracket notation from the following GROQ queries: ``` export const postQuery = ` { "post": *[_type == "post" && slug.current == $slug] | order(_updatedAt desc) [0] { content, ${postFields} }, "morePosts": *[_type == "post" && slug.current != $slug] | order(date desc, _updatedAt desc) [0...2] { content, ${postFields} } }` ``` ### To Reproduce Running the example as it is at the moment throws an error related to this piece of code located at the folder path */lib/queries ``` export const postQuery = ` { "post": *[_type == "post" && slug.current == $slug] | order(_updatedAt desc) | [0] { content, ${postFields} }, "morePosts": *[_type == "post" && slug.current != $slug] | order(date desc, _updatedAt desc) | [0...2] { content, ${postFields} } }` ```
https://github.com/vercel/next.js/issues/31474
https://github.com/vercel/next.js/pull/32182
cffd209a677db9c953c15e4fc8e168a278d3908c
1fe014ce17d999864d474684eb70c1f2172ae9ea
"2021-11-16T03:30:03Z"
javascript
"2021-12-06T19:32:09Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,411
["packages/next/shared/lib/router/utils/prepare-destination.ts", "test/integration/route-index/test/index.test.js"]
Internal Server Error 500: `Invalid regular expression: /:\/: \ at end of pattern`
### What version of Next.js are you using? 12.0.3 ### What version of Node.js are you using? 14.18.1 ### What browser are you using? Any ### What operating system are you using? Any ### How are you deploying your application? next start on Heroku ### Describe the Bug We have an automatic security testing tool that runs on our production sites to check for common vulnerabilities. In the latest run we got a bunch of internal server errors of the type `Invalid regular expression: /:\/: \ at end of pattern` (with different patterns depending on the path visited). Here are the paths that triggered the error: ``` /desktop/core/?.%5C /desktop/core/?.%5C.%5C /desktop/core/?%00 /desktop/core/?%22%27%60%2C%C3%9E~%C3%87%1FY%00 /desktop/core/?%40%5B /desktop/core/?%5C /desktop/core/?%5C.%5C /desktop/core/?%5Cx%5C /desktop/core/?%7C /desktop/core/?bar%60%3C%25%22%27%7B%24%2A%25%5C /desktop/core/?baz%60%3C%25%22%27%7B%24%2A%25%5C /desktop/core/?file%3A%5C /desktop/core/?foo%60%3C%25%22%27%7B%24%2A%25%5C /desktop/core/?hack%3A%5C /desktop/core/?unix:| /desktop/core/?uniz:| /desktop/core/?X5O%21P%25%40AP%5B4%5CPZX54%28P%5E%297CC%297%7D%24EICAR-STANDARD-ANTIVIRUS-TEST-FILE%21%24H%2BH%2A /desktop/core/?Y4O%21P%25%40AP%5B4%5CPZX54%28P%5E%297CC%297%7D%24STANDARD-EICAR-ANTIVIRUS-HACK-FILE%21%24H%2BH%2A /desktop/core/ext-py/?.%5C /desktop/core/ext-py/?.%5C.%5C /desktop/core/ext-py/?%00 /desktop/core/ext-py/?%22%27%60%2C%C3%9E~%C3%87%1FY%00 /desktop/core/ext-py/?%40%5B /desktop/core/ext-py/?%5C /desktop/core/ext-py/?%5C.%5C /desktop/core/ext-py/?%5Cx%5C /desktop/core/ext-py/?%7C /desktop/core/ext-py/?bar%60%3C%25%22%27%7B%24%2A%25%5C /desktop/core/ext-py/?baz%60%3C%25%22%27%7B%24%2A%25%5C /desktop/core/ext-py/?file%3A%5C /desktop/core/ext-py/?foo%60%3C%25%22%27%7B%24%2A%25%5C /desktop/core/ext-py/?hack%3A%5C /desktop/core/ext-py/?unix:| /desktop/core/ext-py/?uniz:| /desktop/core/ext-py/?X5O%21P%25%40AP%5B4%5CPZX54%28P%5E%297CC%297%7D%24EICAR-STANDARD-ANTIVIRUS-TEST-FILE%21%24H%2BH%2A /desktop/core/ext-py/?Y4O%21P%25%40AP%5B4%5CPZX54%28P%5E%297CC%297%7D%24STANDARD-EICAR-ANTIVIRUS-HACK-FILE%21%24H%2BH%2A /desktop/core/ext-py/Paste-2.0.1/?.%5C /desktop/core/ext-py/Paste-2.0.1/?.%5C.%5C /desktop/core/ext-py/Paste-2.0.1/?%00 /desktop/core/ext-py/Paste-2.0.1/?%22%27%60%2C%C3%9E~%C3%87%1FY%00 /desktop/core/ext-py/Paste-2.0.1/?%40%5B /desktop/core/ext-py/Paste-2.0.1/?%5C /desktop/core/ext-py/Paste-2.0.1/?%5C.%5C /desktop/core/ext-py/Paste-2.0.1/?%5Cx%5C /desktop/core/ext-py/Paste-2.0.1/?%7C /desktop/core/ext-py/Paste-2.0.1/?bar%60%3C%25%22%27%7B%24%2A%25%5C /desktop/core/ext-py/Paste-2.0.1/?baz%60%3C%25%22%27%7B%24%2A%25%5C /desktop/core/ext-py/Paste-2.0.1/?file%3A%5C /desktop/core/ext-py/Paste-2.0.1/?foo%60%3C%25%22%27%7B%24%2A%25%5C /desktop/core/ext-py/Paste-2.0.1/?hack%3A%5C /desktop/core/ext-py/Paste-2.0.1/?unix:| /desktop/core/ext-py/Paste-2.0.1/?uniz:| /desktop/core/ext-py/Paste-2.0.1/?X5O%21P%25%40AP%5B4%5CPZX54%28P%5E%297CC%297%7D%24EICAR-STANDARD-ANTIVIRUS-TEST-FILE%21%24H%2BH%2A /desktop/core/ext-py/Paste-2.0.1/?Y4O%21P%25%40AP%5B4%5CPZX54%28P%5E%297CC%297%7D%24STANDARD-EICAR-ANTIVIRUS-HACK-FILE%21%24H%2BH%2A /desktop/core/ext-py/Paste-2.0.1/tests/?.%5C /desktop/core/ext-py/Paste-2.0.1/tests/?.%5C.%5C /desktop/core/ext-py/Paste-2.0.1/tests/?%00 /desktop/core/ext-py/Paste-2.0.1/tests/?%22%27%60%2C%C3%9E~%C3%87%1FY%00 /desktop/core/ext-py/Paste-2.0.1/tests/?%40%5B /desktop/core/ext-py/Paste-2.0.1/tests/?%5C /desktop/core/ext-py/Paste-2.0.1/tests/?%5C.%5C /desktop/core/ext-py/Paste-2.0.1/tests/?%5Cx%5C /desktop/core/ext-py/Paste-2.0.1/tests/?%7C /desktop/core/ext-py/Paste-2.0.1/tests/?bar%60%3C%25%22%27%7B%24%2A%25%5C /desktop/core/ext-py/Paste-2.0.1/tests/?baz%60%3C%25%22%27%7B%24%2A%25%5C /desktop/core/ext-py/Paste-2.0.1/tests/?file%3A%5C /desktop/core/ext-py/Paste-2.0.1/tests/?foo%60%3C%25%22%27%7B%24%2A%25%5C /desktop/core/ext-py/Paste-2.0.1/tests/?hack%3A%5C /desktop/core/ext-py/Paste-2.0.1/tests/?unix:| /desktop/core/ext-py/Paste-2.0.1/tests/?uniz:| /desktop/core/ext-py/Paste-2.0.1/tests/?X5O%21P%25%40AP%5B4%5CPZX54%28P%5E%297CC%297%7D%24EICAR-STANDARD-ANTIVIRUS-TEST-FILE%21%24H%2BH%2A /desktop/core/ext-py/Paste-2.0.1/tests/?Y4O%21P%25%40AP%5B4%5CPZX54%28P%5E%297CC%297%7D%24STANDARD-EICAR-ANTIVIRUS-HACK-FILE%21%24H%2BH%2A /desktop/core/ext-py/Paste-2.0.1/tests/cgiapp_data/?.%5C /desktop/core/ext-py/Paste-2.0.1/tests/cgiapp_data/?.%5C.%5C /desktop/core/ext-py/Paste-2.0.1/tests/cgiapp_data/?%00 /desktop/core/ext-py/Paste-2.0.1/tests/cgiapp_data/?%22%27%60%2C%C3%9E~%C3%87%1FY%00 /desktop/core/ext-py/Paste-2.0.1/tests/cgiapp_data/?%40%5B /desktop/core/ext-py/Paste-2.0.1/tests/cgiapp_data/?%5C /desktop/core/ext-py/Paste-2.0.1/tests/cgiapp_data/?%5C.%5C /desktop/core/ext-py/Paste-2.0.1/tests/cgiapp_data/?%5Cx%5C /desktop/core/ext-py/Paste-2.0.1/tests/cgiapp_data/?%7C /desktop/core/ext-py/Paste-2.0.1/tests/cgiapp_data/?bar%60%3C%25%22%27%7B%24%2A%25%5C /desktop/core/ext-py/Paste-2.0.1/tests/cgiapp_data/?baz%60%3C%25%22%27%7B%24%2A%25%5C /desktop/core/ext-py/Paste-2.0.1/tests/cgiapp_data/?file%3A%5C /desktop/core/ext-py/Paste-2.0.1/tests/cgiapp_data/?foo%60%3C%25%22%27%7B%24%2A%25%5C /desktop/core/ext-py/Paste-2.0.1/tests/cgiapp_data/?hack%3A%5C /desktop/core/ext-py/Paste-2.0.1/tests/cgiapp_data/?unix:| /desktop/core/ext-py/Paste-2.0.1/tests/cgiapp_data/?uniz:| /desktop/core/ext-py/Paste-2.0.1/tests/cgiapp_data/?X5O%21P%25%40AP%5B4%5CPZX54%28P%5E%297CC%297%7D%24EICAR-STANDARD-ANTIVIRUS-TEST-FILE%21%24H%2BH%2A /desktop/core/ext-py/Paste-2.0.1/tests/cgiapp_data/?Y4O%21P%25%40AP%5B4%5CPZX54%28P%5E%297CC%297%7D%24STANDARD-EICAR-ANTIVIRUS-HACK-FILE%21%24H%2BH%2A ``` Here are some example error messages ``` SyntaxError: Invalid regular expression: /:.\.\/: \ at end of pattern SyntaxError: Invalid regular expression: /:.\/: \ at end of pattern SyntaxError: Invalid regular expression: /:@[/: Unterminated character class SyntaxError: Invalid regular expression: /:\.\/: \ at end of pattern SyntaxError: Invalid regular expression: /:\/: \ at end of pattern SyntaxError: Invalid regular expression: /:\x\/: \ at end of pattern SyntaxError: Invalid regular expression: /:bar`<%""'{$*%\/: Nothing to repeat" SyntaxError: Invalid regular expression: /:baz`<%""'{$*%\/: Nothing to repeat" SyntaxError: Invalid regular expression: /:file:\/: \ at end of pattern SyntaxError: Invalid regular expression: /:foo`<%""'{$*%\/: Nothing to repeat" SyntaxError: Invalid regular expression: /:hack:\/: \ at end of pattern SyntaxError: Invalid regular expression: /:X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*/: Range out of order in character class SyntaxError: Invalid regular expression: /:Y4O!P%@AP[4\PZX54(P^)7CC)7}$STANDARD-EICAR-ANTIVIRUS-HACK-FILE!$H+H*/: Range out of order in character class ``` ### Expected Behavior The server should return 404. ### To Reproduce * Generate a new next app with `create-next-app` (v12.0.3 was latest at the time of writing) * Start the server with either `next dev` or `next build && next start` * Visit any of the paths listed above The server will throw an internal server error with a regex message.
https://github.com/vercel/next.js/issues/31411
https://github.com/vercel/next.js/pull/31791
d2cef24d5deae8bb27bf619b970e1aca4f069ec3
8784682a7497cda0e4131014dcb48c42c07ec5ad
"2021-11-15T09:01:22Z"
javascript
"2021-11-30T19:15:13Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,391
["packages/next/build/swc/Cargo.lock", "packages/next/build/swc/crates/core/tests/loader/issue-31627/input.js", "packages/next/build/swc/crates/core/tests/loader/issue-31627/output.js"]
Can't retrieve data from Firestore when `swcMinify: true`
### What version of Next.js are you using? 12.0.3 ### What version of Node.js are you using? 14 ### What browser are you using? Chrome ### What operating system are you using? Linux ### How are you deploying your application? Vercel ### Describe the Bug I'm using Firebase version 9.4.1. I can't get the data by running a query to my Firebase Firestore. This only happens when in production and I enable `swcMinify` in the `next.config.js` file. So, to **fix** it I just disable the `swcMinify` feature and everything is back to normal. ### Expected Behavior Get data from my Firebase Firestore. ### To Reproduce I took just one example that I got from the official Firebase(version 9) documentation to retrieve all data from collections: https://firebase.google.com/docs/firestore/query-data/get-data#get_all_documents_in_a_collection. Then I added a bit of how I implemented it: ```js useEffect(() => { getUser(auth.id, user => { setUser(user) }) }, [auth]) ``` In the `next.config.js` file we enable the `swcMinify` feature. ```js module.exports = { swcMinify: true // .... } ``` Then, you can try running it in production with `next build` then `next start`.
https://github.com/vercel/next.js/issues/31391
https://github.com/vercel/next.js/pull/31639
f52211bad39c2a29a7caba40bfeb89b600524b41
3146ed37f83c0ccade1e2c475a04d82b681385ea
"2021-11-14T12:50:57Z"
javascript
"2021-11-20T19:25:52Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,383
["docs/api-reference/next/server.md"]
Missing cookie in NextResponse obj
### What version of Next.js are you using? 12.0.3 ### What version of Node.js are you using? 14.x ### What browser are you using? Chrome ### What operating system are you using? Window 11 ### How are you deploying your application? next start ### Describe the Bug Hi, I am trying to set cookie with NextResponse which shown in docs, but there is not an obj like that. Is this a future feature ? ![image](https://user-images.githubusercontent.com/15695252/141671008-e9f6c9db-8b6f-48da-9c11-e54a57161cb8.png) ### Expected Behavior Set / remove cookie for NextResponse ### To Reproduce ![image](https://user-images.githubusercontent.com/15695252/141671102-e1b687d1-0a69-4605-9e2a-09487e4e0dd0.png)
https://github.com/vercel/next.js/issues/31383
https://github.com/vercel/next.js/pull/31707
7be75bbf2ff3fbd7daaceb26c6d3318bd79839f8
2781b8eb87bab839960ee59f9f3baae4cec2c983
"2021-11-14T07:06:37Z"
javascript
"2021-11-29T22:44:58Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,375
[".eslintignore", "packages/next/build/jest/jest.ts", "packages/next/build/swc/jest-transformer.js", "packages/next/build/swc/options.js", "packages/next/build/webpack-config.ts", "packages/next/build/webpack/loaders/next-swc-loader.js", "test/development/basic/legacy-decorators.test.ts", "test/development/basic/legacy-decorators/jsconfig.json", "test/development/basic/legacy-decorators/pages/index.js"]
Add support for legacy decorators when enabled in tsconfig/jsconfig
Unfortunately it seems that a group of apps is using legacy decorators in babelrc for integration with older mobx applications. We can add support for this through the `experimentalDecorators` flag in `tsconfig`/`jsconfig` as per @kdy1 that flag is the same as legacy decorators.
https://github.com/vercel/next.js/issues/31375
https://github.com/vercel/next.js/pull/31376
ae1cee59d600b23b6827bffefdcabd9c6605ccf7
e0531e30f4ed12ae32cc0e5d1bdf92953faa7fac
"2021-11-13T15:07:25Z"
javascript
"2021-11-13T17:26:13Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,359
["packages/next/build/swc/options.js", "packages/next/build/webpack-config.ts", "packages/next/build/webpack/loaders/next-swc-loader.js", "test/development/basic/theme-ui.test.ts", "test/development/basic/theme-ui/jsconfig.json", "test/development/basic/theme-ui/pages/_app.js", "test/development/basic/theme-ui/pages/index.js", "test/development/basic/theme-ui/theme.js"]
Add support for importSource
One of the items in https://github.com/vercel/next.js/discussions/30174#discussion-3643870
https://github.com/vercel/next.js/issues/31359
https://github.com/vercel/next.js/pull/31358
06f3d398b1fb728bcce8e11b848b5ad9370b490c
a4692d400d666194eb037c5a842f702e259ba1c5
"2021-11-12T20:06:44Z"
javascript
"2021-11-12T20:51:43Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,337
["docs/api-reference/next/router.md"]
Document router.push returns a promise
### Discussed in https://github.com/vercel/next.js/discussions/31278 <div type='discussions-op-text'> <sup>Originally posted by **TrueWill** November 11, 2021</sup> I'm not quite sure where to post this - is it a bug? a feature? an issue with the docs? I turned on the [no-floating-promises](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-floating-promises.md) ESLint rule, and suddenly all of my `router.push` (and other router methods) were flagged. Per the typedefs it returns `Promise<boolean>` - but this isn't [documented](https://nextjs.org/docs/api-reference/next/router#routerpush). The examples ignore the returned promise. Is there a reason for this behavior?</div>
https://github.com/vercel/next.js/issues/31337
https://github.com/vercel/next.js/pull/31341
6ffa2baa4d0392cddc462eb3788b8c9befb42546
f176683806acda157277e27ca861e1dff62e04df
"2021-11-12T09:22:43Z"
javascript
"2021-12-19T23:07:11Z"
closed
vercel/next.js
https://github.com/vercel/next.js
33,538
["packages/next/build/webpack-config.ts", "packages/next/build/webpack/loaders/next-flight-client-loader.ts", "packages/next/build/webpack/plugins/flight-manifest-plugin.ts", "test/integration/react-streaming-and-server-components/app/components/named.client.js", "test/integration/react-streaming-and-server-components/app/pages/index.server.js", "test/integration/react-streaming-and-server-components/test/rsc.js"]
Named exports of components are not supported
It is not possible to use named imports/exports for components, i.e. this works: ```tsx export default function Page() { ... } ``` and this doesn't work ```tsx export function Page() { ... } ``` resulting in the following error: ``` error - unhandledRejection: SyntaxError: Unexpected token u in JSON at position 0 ``` Here's a minimal code to reproduce: https://github.com/vercel/next-rsc-demo/compare/main...zaiste:named-imports-for-components
https://github.com/vercel/next.js/issues/33538
https://github.com/vercel/next.js/pull/34974
1b17070a2972646a94de9f652510066c94c6c7c3
1f1632979c78b3edfe59fd85d8cce62efcdee688
"2021-11-11T20:45:10Z"
javascript
"2022-03-02T20:57:50Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,291
["packages/next/build/swc/Cargo.lock", "packages/next/build/swc/crates/core/tests/loader/issue-31627/input.js", "packages/next/build/swc/crates/core/tests/loader/issue-31627/output.js"]
Optimisations no longer applied to `_buildManifest.js` when using SWC
### What version of Next.js are you using? 12.0.4-canary.4 ### What version of Node.js are you using? 16.13.0 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? Vercel ### Describe the Bug After enabling SWC I noticed that `buildManfest.json`'s output grew significantly (20kb⇢80kb) because it is no longer using optimisations for chunk names, e.g: `self.__BUILD_MANIFEST=function(e,s,a,t,c,o,n,i,r,g,l,b,d,u,p,f,h,m,k)` ``` // With SWC off: ls -lh .next/static/JdI1kHMMIQ4b_kwr2NZiG/_buildManifest.js -rw-r--r-- 1 benschwarz staff 26K 11 Nov 18:58 .next/static/JdI1kHMMIQ4b_kwr2NZiG/_buildManifest.js // With SWC on: ls -lh .next/static/dtDJS-Od0qktpqIrQBB_S/_buildManifest.js -rw-r--r-- 1 benschwarz staff 80K 11 Nov 18:51 .next/static/dtDJS-Od0qktpqIrQBB_S/_buildManifest.js ``` Over the wire (with Gzip compression) the file size difference isn't anywhere near as dramatic (Repeated strings are of course optimised by Gzip, so they both end up around 6kb), **but** there may be an impact to JS parse & compile times, which could compromise main thread performance for sites with many pages. ### Expected Behavior Optimisations should be applied to `_buildManifest.js` to avoid a potential perf regression. ### To Reproduce * Run `rm -rf .next` * Run `next build` * Observe size of `.next/static/<generatedHash>/_buildManifest.js` (small) * Run `rm -rf .next` * Turn on SWC using `swcMinify: true` in `next.config.json` * Run `next build` * Observe size of `.next/static/<generatedHash>/_buildManifest.js` (large)
https://github.com/vercel/next.js/issues/31291
https://github.com/vercel/next.js/pull/31639
f52211bad39c2a29a7caba40bfeb89b600524b41
3146ed37f83c0ccade1e2c475a04d82b681385ea
"2021-11-11T08:07:12Z"
javascript
"2021-11-20T19:25:52Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,286
["examples/auth0/pages/advanced/ssr-profile.js"]
Auth0 API Call Incorrect in Example
### What version of Next.js are you using? canary ### What version of Node.js are you using? 15.10.0 ### What browser are you using? Firefox ### What operating system are you using? macOS ### How are you deploying your application? `npm run dev` ### Describe the Bug API signature mismatch between the example code and the Auth0 library. Required parameter (`res`) missing. Fix opened in #31284. ### Expected Behavior Profile page should load! ### To Reproduce Run the [Auth0 example](https://github.com/vercel/next.js/tree/canary/examples/auth0) without the fix in PR #31284 and navigate to the server-rendered profile.
https://github.com/vercel/next.js/issues/31286
https://github.com/vercel/next.js/pull/31284
ae1d271f9ab77c63036d4901155a089d13392ea2
5014362a7a6359fac8fc1bb8a02eae6736805d7f
"2021-11-11T02:40:54Z"
javascript
"2021-11-11T03:16:31Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,275
["packages/next/build/webpack-config.ts", "test/e2e/next-script/index.test.ts"]
Unable to use `dangerouslySetInnerHTML` and `beforeInteractive` strategy in Script component
### What version of Next.js are you using? 14.17.1 ### What version of Node.js are you using? 12.0.3 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? npm run dev ### Describe the Bug Setting `dangerouslySetInnerHtml` in next Script component while also specifying `beforeInteractive` strategy will result in the Script component doing nothing. Since there is no `src` specified, the src will simply be `(unknown)`. ![script](https://user-images.githubusercontent.com/19775351/141206853-62aed528-260b-46e2-9278-dbc5f8161b70.PNG) ``` <Script id="test" strategy="beforeInteractive" dangerouslySetInnerHTML={{ // will not run __html: `console.log('hello!')`, }} /> ``` ### Expected Behavior Script component can be used with no `src` while using `dangerouslySetInnerHtml` property. ### To Reproduce Try to render Script component using `beforeInteractive` while having no `url` and specifying `dangerouslySetInnerHtml` property. ``` <Script id="test" strategy="beforeInteractive" dangerouslySetInnerHTML={{ // will not run __html: `console.log('hello!')`, }} /> ``` This piece of code of next Script will result in the following script tag being added ![script](https://user-images.githubusercontent.com/19775351/141207463-f8d3f16d-44bd-4dae-806e-7fc3f2980ceb.PNG)
https://github.com/vercel/next.js/issues/31275
https://github.com/vercel/next.js/pull/37000
b2045c7669982edbb7002c7f88f8e7665a2168f7
81e69e8662e5d4010b1ca726092479f777b0e4d7
"2021-11-10T22:56:17Z"
javascript
"2022-05-18T18:36:11Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,254
["package.json", "packages/next/server/image-optimizer.ts", "packages/next/server/lib/squoosh/impl.ts", "packages/next/server/lib/squoosh/main.ts", "test/integration/image-optimizer/app/public/mountains.jpg", "test/integration/image-optimizer/test/index.test.js", "yarn.lock"]
New avif image larger than webp
### What version of Next.js are you using? 12.0.3 ### What version of Node.js are you using? v16.4.0 ### What browser are you using? Chrome ### What operating system are you using? Mac (local dev environment) ### How are you deploying your application? next start ### Describe the Bug The new avif image format was introduced with "enabling 20% smaller images compared to WebP.". Unfortunately, my local tests show me the opposite. **Example result:** Avif: 96,4kb <img width="959" alt="Bildschirmfoto 2021-11-10 um 16 06 41" src="https://user-images.githubusercontent.com/6911678/141142280-d21aff51-57fa-4073-bf5f-1bacfd1dff14.png"> Webp: 82,6kb <img width="953" alt="Bildschirmfoto 2021-11-10 um 16 06 17" src="https://user-images.githubusercontent.com/6911678/141142216-9f168bf3-b1ed-4463-b03b-695610225b6a.png"> I know the efficiency of image compression algorithms depends on the image, that's why I tested this with multiple images. But I always had a similar result. ### Expected Behavior The Avif Image should not be larger than the webp image. ### To Reproduce ### Short Version: I created a example project to show this problem: https://github.com/derweili/next-image-compression-test 1. Clone this repo: https://github.com/derweili/next-image-compression-test 2. Run `npm run build && npm run start` 3. Load the page in the Browser and check the image size via the dev tools (network tab) 4. Comment out line 7 of the next.config.js file https://github.com/derweili/next-image-compression-test/blob/79c14ce248db4b9b00740ffd8307b98a327e4a50/next.config.js#L7 5. Run `npm run build && npm run start` again 6. Load the page in the Browser and check the image size via the dev tools (network tab) 7. Compare both image sizes ### Manual version: 1. Create a new nextjs project using create-next-app 2. Add a random photo 3. Run `npm run build && npm run start` 4. Load the page in the Browser and check the image size via the dev tools (network tab) 5. Add avif support as described here: https://nextjs.org/blog/next-12#smaller-images-using-avif 6. Run `npm run build && npm run start` again 7. Load the page in the Browser and check the image size via the dev tools (network tab) 8. Compare both image sizes
https://github.com/vercel/next.js/issues/31254
https://github.com/vercel/next.js/pull/31494
0cf7061859c1a00979247a552423a1812f8e1081
44b4dbcd419b592bea354161a309e0f74dfa67d1
"2021-11-10T15:31:23Z"
javascript
"2021-11-17T20:31:16Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,250
["packages/next-swc/Cargo.lock", "packages/next-swc/crates/core/Cargo.toml", "packages/next-swc/crates/core/src/next_ssg.rs", "packages/next-swc/crates/core/src/page_config.rs", "packages/next-swc/crates/core/src/shake_exports.rs", "packages/next-swc/crates/core/tests/full/auto-cjs/1/output.js", "packages/next-swc/crates/core/tests/full/example/output.js", "packages/next-swc/crates/napi/Cargo.toml", "packages/next-swc/crates/napi/src/bundle/mod.rs", "packages/next-swc/crates/wasm/Cargo.toml"]
Error `Objects are not valid as a React child (found: object with keys...` with `swcMinify: true`
### What version of Next.js are you using? v12.0.3 and v12.0.4-canary.4 ### What version of Node.js are you using? v16.3.0 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? next build && next start ### Describe the Bug #### With **`swcMinify: false`** in `next.config.js`: When running `next build && next start` or `next dev` , after opening `http://localhost:3000/` in the browser, everything works fine and is rendered correctly, there are no errors in the console. #### With **`swcMinify: true`** in `next.config.js`: - After running `next dev` and opening `http://localhost:3000/` in the browser everything is still working fine - However running `next build && next start`, after opening `http://localhost:3000/` in the browser instead of the rendered page you see: `Application error: a client-side exception has occurred (see the browser console for more information).`, with the [following error in the console](https://gist.github.com/martinfrancois/d8d59f5c11acea980b997cb696f1d3c6). When decoded, it results in the following errors: ``` Objects are not valid as a React child (found: object with keys {Qr, RV, cI, Gc}). If you meant to render a collection of children, use an array instead. Objects are not valid as a React child (found: object with keys {passive}). If you meant to render a collection of children, use an array instead. ``` ### Expected Behavior Having **`swcMinify: true`** in `next.config.js` should result in the same page being rendered after running `next build && next start` as when having **`swcMinify: false`** in `next.config.js` and should be rendered without any errors. ### To Reproduce 1. Clone https://github.com/martinfrancois/swc-minification-repro 2. `npm ci` 3. `npm run build` 4. `npm start` 5. Open http://localhost:3000/ in your browser.
https://github.com/vercel/next.js/issues/31250
https://github.com/vercel/next.js/pull/33063
320986a2b897bc512c21f7148f4a4c8ce749dcae
87dbd03eb0ca738fbf669e1f03826af6e59b9b27
"2021-11-10T14:01:29Z"
javascript
"2022-01-10T10:37:32Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,241
["packages/next/cli/next-telemetry.ts", "packages/next/telemetry/storage.ts"]
Make `npx next telemetry disable` output where the preference setting was saved to
### Describe the feature you'd like to request For this message: ``` $ npx next telemetry disable Your preference has been saved. Status: Disabled You have opted-out of Next.js' anonymous telemetry program. No data will be collected from your machine. Learn more: https://nextjs.org/telemetry ``` I find it unsettling to see there were no changes in my git repo. ### Describe the solution you'd like Instead of `Your preference has been saved.` it would be lovely to see it say something like `Your preference has been saved to /home/user/somethingsomething` ### Describe alternatives you've considered Using [sysinternals](https://docs.microsoft.com/en-us/sysinternals/downloads/filemon)
https://github.com/vercel/next.js/issues/31241
https://github.com/vercel/next.js/pull/31305
fbe366f4656a29f8ef03b7ee66c38ab9f642d665
c4558c913f4f2ce95fccae92a182127a0a451954
"2021-11-10T11:21:49Z"
javascript
"2021-11-11T16:48:00Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,228
["packages/next/server/router.ts", "test/integration/i18n-support/test/index.test.js"]
i18n configuration. The pathname can contain 2 different locales and it works (f.e. /en/de/).
### What version of Next.js are you using? 12.0.3 ### What version of Node.js are you using? 14.17.5 ### What browser are you using? Chrome ### What operating system are you using? Windows ### How are you deploying your application? next start ### Describe the Bug When I use [i18n configuration](https://nextjs.org/docs/advanced-features/i18n-routing) I can see page in 3 difference urls. For example, if I have page `/cards/` - it will be available at: 1. `/cards/` (_that's ok, we expect it_) 2. `/en/cards/` (_that's ok too_) 3. `/en/de/cards/` (_what?_) (_In the last case language will be `/de/`_) ### Expected Behavior The page should be available only at: 1. `/cards/` (_that's ok, we expect it_) 2. `/en/cards/` (_that's ok too_) Not at `/en/de/cards/`. On this page I am expecting a 404 error ### To Reproduce Enable i18n in some project. Here a good example with this error: https://github.com/vercel/next.js/tree/canary/examples/i18n-routing The main page will be available at ` `, `/en`, `/en/nl`; `gsp` - at `/gsp`, `/en/gsp`, `/en/fr/gsp`; etc
https://github.com/vercel/next.js/issues/31228
https://github.com/vercel/next.js/pull/31229
c791da09779e5ec005fd3b01a46872676817db18
ae1d271f9ab77c63036d4901155a089d13392ea2
"2021-11-09T22:28:19Z"
javascript
"2021-11-11T02:29:20Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,196
["packages/next/server/web/spec-extension/response.ts", "test/unit/web-runtime/next-response.test.ts"]
NextResponse: Auto detect JSON payload
### Describe the feature you'd like to request Allow for `NextResponse` to add Content-Type and body stringify automatically when input is JSON. ### Describe the solution you'd like Instead of ```js new Response(JSON.stringify({ message: 'hi' }), { headers: { 'content-type': 'application/json' } }) ``` The interface could be: ```js new NextResponse({ message: 'hi' }) ``` ### Describe alternatives you've considered Maybe checking the payloads could be too hard, consider `NextResponse.json()` could be a better approach.
https://github.com/vercel/next.js/issues/31196
https://github.com/vercel/next.js/pull/31483
af82de42741341daf2561a297dbbd54e4f3f8e8a
593d943cd05c388133879750b2197926601a43e0
"2021-11-09T10:44:55Z"
javascript
"2021-11-16T18:38:47Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,179
["packages/next/server/next-server.ts", "test/integration/middleware/core/test/index.test.js"]
next/server proxies middleware rewrites if not served from localhost
### What version of Next.js are you using? 12.0.4-canary.0 ### What version of Node.js are you using? 16.11.0 ### What browser are you using? Firefox ### What operating system are you using? macOS ### How are you deploying your application? next start ### Describe the Bug When returning `NextResponse.rewrite` from middleware, next/server determines whether to proxy the request by checking if the parsed rewrite URL has a protocol. When running on localhost this will be false, so it will handle the rewrite as expected. However if running with a hostname, such as if using `mycomputername.local:3000`, using any other value for localhost (such as `127.0.0.1`), or running a live server, then the parsed URL will have a protocol, so the server will attempt to proxy to the address. This will result in either an ssl error or a proxy loop. I am happy to submit a PR to fix this. It can be fixed by also checking if the rewrite host matches the request host. ### Expected Behavior Server does not attempt to proxy local rewrites, even when running with a hostname. ### To Reproduce - Clone [the geolocation demo](https://github.com/vercel/examples/tree/main/edge-functions/geolocation) - Run locally - Load using your computer's hostname, or `localtest.me` (which resolves to localhost)
https://github.com/vercel/next.js/issues/31179
https://github.com/vercel/next.js/pull/31180
d1adf1d5039fa3cba78409509f80b3958b60eeaa
9952cc79dbbfe81723cba0c0e6ba2250c3921964
"2021-11-08T21:58:39Z"
javascript
"2021-11-13T00:20:13Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,149
["packages/next/lib/typescript/writeConfigurationDefaults.ts"]
False Requirement: isolatedModules is set to true for babel when not using babel
### What version of Next.js are you using? 12.0.3 ### What version of Node.js are you using? 16.9.4 ### What browser are you using? Chrome ### What operating system are you using? Ubuntu ### How are you deploying your application? vercel ### Describe the Bug A dependency does not have isolatedModules and thus breaks `next build`. We are not using babel anymore in favor of swc. `The following mandatory changes were made to your tsconfig.json:` `- isolatedModules was set to true (requirement for babel)` Then the build fails because of no isolated modules ### Expected Behavior Allow isolatedModules or enhance error message ### To Reproduce Set `isolatedModules` in `tsconfig.json` to `true` and run `next build`.
https://github.com/vercel/next.js/issues/31149
https://github.com/vercel/next.js/pull/31150
283af4e69bd86e108ae712cbf6921e3f143b40f1
9d7900c209329682308cc1a6093f297deae43662
"2021-11-08T13:46:05Z"
javascript
"2021-11-08T19:16:34Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,139
["packages/next/client/dev/error-overlay/websocket.ts"]
Next v12 upgrade: WebSocket connection to 'wss://localhost:3000/_next/webpack-hmr' failed: for https connections
### What version of Next.js are you using? 12.0.3 ### What version of Node.js are you using? 14.17.6 ### What browser are you using? Chrome ### What operating system are you using? macOS ### Describe the Bug Post v12.0.3 migration, when I try to run the application locally via https URL, `https://dev.abcd.com:443`; it throws the error `WebSocket connection to 'wss://localhost:3000/_next/webpack-hmr' failed`. `http://localhost:3000` was set as assertPrefix. However, It works fine when I try to use http URL, `http://dev.abcd.com:3000` ____________________ After digging a bit I found that, the cause was that the websocket connections for `ws://localhost:3000/_next/webpack-hmr` worked well, but `wss://localhost:443/_next/webpack-hmr` failed. I can't figure out why secure connections are failing #30491 did not help as I'm neither using nginx, nor a custom express server.
https://github.com/vercel/next.js/issues/31139
https://github.com/vercel/next.js/pull/31213
489ca73e436c54408b8769437d5fd51bb336d6f4
e3135ccde61c8bed2398962c1a24548a1f774757
"2021-11-08T11:29:24Z"
javascript
"2021-11-09T21:26:55Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,104
["packages/next/build/entries.ts", "packages/next/build/webpack-config.ts", "packages/next/pages/_document-web.tsx", "packages/next/taskfile.js"]
[Expo] [WebDocument] TypeError: Cannot call a class as a function
### What version of Next.js are you using? 12.0.3 ### What version of Node.js are you using? 16.7.0 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? N/A ### Describe the Bug After updating to 12.0.3 from 12.0.2, I'm now getting a build error: ``` Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. TypeError: Cannot call a class as a function at _classCallCheck (webpack-internal:///./node_modules/@babel/runtime/helpers/classCallCheck.js:3:11) at WebDocument (webpack-internal:///./pages/_document.tsx:90:85) at processChild (/myproject/node_modules/react-dom/cjs/react-dom-server.node.development.js:3353:14) at resolve (/myproject/node_modules/react-dom/cjs/react-dom-server.node.development.js:3270:5) at ReactDOMServerRenderer.render (/myproject/node_modules/react-dom/cjs/react-dom-server.node.development.js:3753:22) at ReactDOMServerRenderer.read (/myproject/node_modules/react-dom/cjs/react-dom-server.node.development.js:3690:29) at Object.renderToStaticMarkup (/myproject/node_modules/react-dom/cjs/react-dom-server.node.development.js:4314:27) at Object.renderToHTML (/myproject/node_modules/next/dist/server/render.js:739:41) at async doRender (/myproject/node_modules/next/dist/server/next-server.js:1389:38) at async /myproject/node_modules/next/dist/server/next-server.js:1484:28 ``` ### Expected Behavior This was working correctly in 12.0.2. If I had to guess I think the culprit is the new `_document.web.tsx` file that was added in https://github.com/vercel/next.js/pull/30963/files#diff-19e859eeb1baeee864c9a093b1eda99c402b707ac813857330747f42cdfbb979 (cc @huozhi) that's being picked up instead of `_document.tsx` by RNW/Expo projects. ### To Reproduce One way to reproduce is to add Expo to a Next.js project https://docs.expo.dev/guides/using-nextjs/#add-expo-to-nextjs-projects This is my `pages/_document.tsx` ```tsx import { Document, getInitialProps } from '@expo/next-adapter/document' import React from 'react' import { flush } from 'react-native-media-query' export default class WebDocument extends Document { static getInitialProps: typeof getInitialProps = async ({ renderPage }) => { const initialProps = await getInitialProps({ renderPage }) const styles = [initialProps.styles, flush()] return { ...initialProps, styles: React.Children.toArray(styles) } } } ```
https://github.com/vercel/next.js/issues/31104
https://github.com/vercel/next.js/pull/31116
ad981783abbb347b6510c4dee5ce969e87ab0e24
cfb8cc841e6c7b80e809565cddfc4219d695c282
"2021-11-07T04:18:20Z"
javascript
"2021-11-07T22:14:50Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,077
["packages/next-swc/Cargo.lock"]
swc broken on nextjs 12.0.3 with @toast-ui/react-editor
### What version of Next.js are you using? 12.0.3 ### What version of Node.js are you using? v16.13.0 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? next build ### Describe the Bug when i add `@toast-ui/react-editor` to my project i change i config `swcMinify: true,` then i run `next build` i got a error: ``` yarn run v1.22.17 $ next build warn - SWC minify beta enabled. https://nextjs.org/docs/messages/swc-minify-enabled info - Checking validity of types info - Creating an optimized production build .thread '<unnamed>' panicked at 'Infinite loop detected (current pass = 101)', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc_ecma_minifier-0.48.4/src/compress/mod.rs:261:13 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace fatal runtime error: failed to initiate panic, error 5 error Command failed with signal "SIGABRT". info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. ``` ### Expected Behavior no error ### To Reproduce 1. clone https://github.com/find456789/tmp_nextjs12_swc 2. `yarn` or `npm i` 3. `yarn build` or `npm run build` you will got the error
https://github.com/vercel/next.js/issues/31077
https://github.com/vercel/next.js/pull/33461
e5dee17f776dcc79ebb269f7b7341fa6e2b6c3f1
3574b91b48fabc20ba007953dbf3d6b52cfa37a1
"2021-11-06T09:35:47Z"
javascript
"2022-01-19T15:57:39Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,013
["packages/next/shared/lib/router/router.ts", "test/integration/middleware/with-base-path/pages/_middleware.js", "test/integration/middleware/with-base-path/pages/index.js", "test/integration/middleware/with-base-path/test/index.test.js"]
HEAD prefetch requests caused by middleware do not respect basePath
### What version of Next.js are you using? 12.0.2 ### What version of Node.js are you using? 14 ### What browser are you using? Chrome ### What operating system are you using? macOs ### How are you deploying your application? next start ### Describe the Bug When having a basePath in next-config and some middleware then next.js fires HEAD request for link prefetching. These HEAD request do not respect basePath. ### Expected Behavior HEAD request respects basePath. ### To Reproduce repository to reproduce: https://github.com/alfrescian/next-middleware-base-path-issue next-config:`module.exports = { basePath: "/my-base" };` You'll notice HEAD request go to http://localhost:3000/blend9709 instead of expected http://localhost:3000/my-base/blend9709
https://github.com/vercel/next.js/issues/31013
https://github.com/vercel/next.js/pull/31101
3e8b2dcb6c64b4031ae7dbee813a295a064191b9
764e29c170ce2c1c779329d3ab16a15caa00081a
"2021-11-05T09:40:02Z"
javascript
"2021-11-09T19:03:05Z"
closed
vercel/next.js
https://github.com/vercel/next.js
31,012
["packages/next/build/output/index.ts", "test/integration/amphtml/pages/invalid-amp.js", "test/integration/amphtml/test/index.test.js"]
AMP Validator error logs are shown vertically
### What version of Next.js are you using? 12.0.2 ### What version of Node.js are you using? v14.16.0 ### What browser are you using? Chorme ### What operating system are you using? macOS ### How are you deploying your application? local development ### Describe the Bug AMP Validator error logs are shown vertically. ![スクリーンショット 2021-11-05 17 58 57](https://user-images.githubusercontent.com/12580072/140485481-53afc404-2802-4a4a-8d95-2203e17df578.png) It might be caused by this PR. https://github.com/vercel/next.js/pull/29753/files ### Expected Behavior I expected to show the correctly formatted logs. ![スクリーンショット 2021-11-05 18 05 43](https://user-images.githubusercontent.com/12580072/140485685-9086e19c-30d3-4d03-bf4f-efcd8b610435.png) ### To Reproduce run `/examples/amp-first`. https://github.com/vercel/next.js/tree/canary/examples/amp-first
https://github.com/vercel/next.js/issues/31012
https://github.com/vercel/next.js/pull/31018
e9e8e8b423c9c59f1a54db35d282ff20c825a949
4c05de3c7e1a6c920e5f8d5f1e740e7b48e1321a
"2021-11-05T09:09:52Z"
javascript
"2021-11-26T15:13:09Z"
closed
vercel/next.js
https://github.com/vercel/next.js
30,989
["packages/next/build/entries.ts", "packages/next/build/webpack/loaders/next-middleware-ssr-loader/index.ts", "packages/next/server/dev/hot-reloader.ts", "test/integration/react-streaming-and-server-components/app/pages/err.js", "test/integration/react-streaming-and-server-components/app/pages/err/render.js", "test/integration/react-streaming-and-server-components/app/pages/err/suspense.js", "test/integration/react-streaming-and-server-components/test/index.test.js"]
Error routes (404, 500) in React Server Components
### Describe the feature you'd like to request Support for these features, with correct status codes. https://nextjs.org/docs/advanced-features/custom-error-page ### Describe the solution you'd like TBD ### Describe alternatives you've considered N/A
https://github.com/vercel/next.js/issues/30989
https://github.com/vercel/next.js/pull/31164
eb0bd63af48ea9bec85670ad1bcbc455c5f879ec
ef5795327a99ec8a3dfbe0b40fc1fdde3cdc58fb
"2021-11-04T21:21:30Z"
javascript
"2021-11-15T17:49:50Z"
closed
vercel/next.js
https://github.com/vercel/next.js
30,962
["docs/api-reference/next/script.md", "docs/basic-features/script.md", "packages/next/client/script.tsx", "test/integration/script-loader/base/pages/page8.js", "test/integration/script-loader/base/pages/page9.js", "test/integration/script-loader/test/index.test.js"]
next/script onLoad run once per cache Key (id, src)
### What version of Next.js are you using? 12.0.2 ### What version of Node.js are you using? 14.18.1 ### What browser are you using? Chrome ### What operating system are you using? macOS ### How are you deploying your application? codesandbox ### Describe the Bug When using more than one `Script` with same `id` or `src`, only first script that complete load trigger the `onLoad` prop. Same problem happens using one `Script` but after unmount and remount, for example when navigating throughout client-side router the `onLoad` will not be called. @giorgiabosello ### Expected Behavior `Script` component should load once the src script but run `onLoad` on component did mount and script is loaded. ### To Reproduce https://codesandbox.io/s/nextjs-script-onload-ltm95
https://github.com/vercel/next.js/issues/30962
https://github.com/vercel/next.js/pull/38849
85b00b2ccae5629d3561b0c85579c9455693244c
a8186065b8eb30ef73d82075dbeb2a6fd94c2eaa
"2021-11-04T15:30:19Z"
javascript
"2022-07-28T20:42:52Z"