Commit graph

7585 commits

Author SHA1 Message Date
Tim Neutkens
febb06558f
Update bug_report.yml 2021-01-04 11:36:35 +01:00
Tim Neutkens
5cb8aee415
Update bug_report.yml 2021-01-04 11:35:53 +01:00
Tim Neutkens
6c4ee56ec9
Update bug_report.yml 2021-01-04 11:35:30 +01:00
Tim Neutkens
4a296d55eb
Create bug_report.yml 2021-01-04 11:30:35 +01:00
Alexander Kachkaev
7076758c8d
Call res.write('') inside apiRes.redirect() helper to prevent an edge case (#20461)
This PR is a small follow-up to #14705. It saves Next.js users from falling into a [pretty nasty trap](https://github.com/nodejs/node/issues/36620) in which I ended up last Friday. It took more than two days to investigate what was going on, so I hope I'm the last person who’s doing it 😅

Next.js-specific MWE: https://github.com/kachkaev/hanging-response-in-next-via-redirect-plus-compression (needs to be ran locally using Node 14.0.0+).

> <img width="521" alt="Screenshot 2020-12-24 at 20 50 00" src="https://user-images.githubusercontent.com/608862/103105989-a9b8dc00-4629-11eb-9be3-5108755604bf.png">

To reproduce the bug I’m fixing:

1. Pick a large http body size (64 or 128 KB)
1. Check _Call res.end() after res.redirect() in /api/redirect_
1. Navigate to a heavy page or an api handler via redirect
1. Observe that the http response is never finished.

If you set `compress` to `false` in `next.config.js` or pick a small payload size (< `zlib.Z_DEFAULT_CHUNK` after compression), the bug will not be observed. This is explained by the use of `res.on("drain", ...)` [by the `compression` package](3fea81d0ea/index.js (L193-L218)). The package itself is not the reason for an issue though, it seems to be in the Node’s built-in `http` package.

I’m happy to provide more info or GitHub CI to the MWE if needed. I was also thinking of adding some Next.js-specific testing, but could not come up with a compact and clear test plan. Happy to do this if there are any ideas.

cc @botv (author of #14705)
2021-01-04 10:14:15 +00:00
Tim Neutkens
74166ea7e8
Remove outdated documentation (#20714)
Fixes #20487
2021-01-04 10:45:57 +01:00
Leo Lamprecht
9a0d704f76
Clarify how to use Environment Variables on Vercel (#20708)
Updates the env documentation to mention `.vercelignore` when using the Vercel CLI. Also clears up parts of the other paragraphs and updates the links as these topics now have dedicated pages in the Vercel docs.
2021-01-04 09:42:57 +00:00
JJ Kasper
88b6c47244
Ensure isReady is set correctly for auto static dynamic route (#20729)
Follow-up to https://github.com/vercel/next.js/pull/20628 this ensures `isReady` is not initially true when the query isn't present but the page is an automatically statically optimized dynamic route
2021-01-04 08:58:52 +00:00
Vitali Zaidman
9ff378559d
Improve the "why did you render" library example and readme (#20712) 2021-01-03 16:21:33 +00:00
tarunama
8795369a2d
chore(client-image): add return types (#20686) 2021-01-03 15:59:17 +00:00
Frédéric Montet
98752eb0f1
Update link.md (#20435)
Added the `locale` prop in the Link documentation. At the moment it is only stated in the i18n doc.
2021-01-03 14:48:54 +00:00
Zach Bialecki
f412547248
Don't dedupe meta tags with the same name but unique keys (#17099)
Currently there is no way to add multiple meta tags with the same name attribute to the head of a page. This PR modifies the Head component to allow multiple meta tags with the same name if they have unique keys. 

This is important for integrating with certain services like Google Scholar and Swiftype.

Fixes #10183
2021-01-03 10:35:51 +00:00
Joe Haddad
85bd4a9ccb
v10.0.5-canary.8 2021-01-01 21:40:09 -05:00
Joe Haddad
58ea3bb479
fix(next/babel): read env from caller, not process (#20679)
This PR fixes a bug where `next/babel` would accidentally enable development transforms for a production build (`next build`).

This is tested by the two updated unit tests (which removed a workaround for this bug, and one now properly enables dev transforms).

---

Fixes #18929
Fixes #19001
x-ref #19046
x-ref #17032
2021-01-02 00:36:16 +00:00
Joe Haddad
984ac96dc6
chore: remove old traces of next/data experiment (#20678)
This PR removes some left over traces of the `next/data` experiment, as it has been superseded by RSC.
2021-01-01 22:23:42 +00:00
JJ Kasper
dffb47133b v10.0.5-canary.7 2021-01-01 14:34:29 -06:00
Joe Haddad
2c75fa0d9e
fix(source map): correctly generate source maps (#20672)
Fixes #20500
2021-01-01 20:30:50 +00:00
Justin Eder
9ded7aa955
Update to Tailwind CSS 2.0 in blog-starter-typescript example (#20664)
This updates the blog-starter-typescript example to use the latest version of Tailwind CSS (2.0.2)

Notes:
Followed the upgrade guide here: https://tailwindcss.com/docs/upgrading-to-v2 
And Next / PostCSS guide here: https://nextjs.org/docs/advanced-features/customizing-postcss-config
2021-01-01 18:45:55 +00:00
JJ Kasper
8b803d79a9
Update error when internal href and external as are used (#20658)
* Update error when internal href and external as are used

* Update to handle error outside invariant

* Update err.sh components
2021-01-01 12:14:42 -06:00
JJ Kasper
fad3256091
Update docs for basePath: false rewrite (#20663) 2021-01-01 12:40:25 -05:00
JJ Kasper
9c8d04654e
Ensure all entries are cleared from cache on runtime change (#20652) 2021-01-01 12:39:39 -05:00
Luke Harries
16d464caf6
Fix withSourceMaps is not a function (#20643)
In order to get this example working, I needed to remove the invocation as described here: https://github.com/vercel/next-plugins/issues/309#issuecomment-674376348
2020-12-31 22:00:41 +00:00
Joe Haddad
29b591b2bc
fix(next/image): do not pass-through srcSrc on lazy image (#20651)
This PR fixes a bug where we'd accidentally pass-through the user-provided `srcSet` if the image was lazy, just to then replace it when we hydrate.

---

Fixes #19041
2020-12-31 21:08:57 +00:00
子慕大诗人
088f374c16
Fix react-dev-overlay rem style conflict (#17723)
### Don‘t use rem in react-dev-overlay.
If we create a nextjs project and use css rem. We could set the html fontsize to any 'px'.  The react-dev-overlay components styles will be affected so that the style becomes larger or smaller.

![image](https://user-images.githubusercontent.com/10840654/95490394-c189a800-09ca-11eb-816a-8bcaf6bcb657.png)
## So i suggest change the rem to px.
## After modification:
![image](https://user-images.githubusercontent.com/10840654/95490703-2e9d3d80-09cb-11eb-8369-7ec650fa6c52.png)

---

Fixes #18680
2020-12-31 19:27:15 +00:00
Joe Haddad
e4a744653d
fix(overlay): skip disable & upgrade platform (#20647)
This bundles ally.js into Next.js itself to upgrade a dependency they have pinned.

I tried every other major focus trap solution, even those used by some modal libraries, and they all failed.

`ally.js` is the only library that can do it correctly, so we're going to stick with it.

I also removed the `maintain/disabled` as we have a backdrop that would effectively result in the same. This reduces CPU strain.

---

Fixes #19893
Fixes #14369
Closes #14372
2020-12-31 19:04:46 +00:00
enoch ndika
44ee7de664
example with-mdbreact (#19879)
This example illustrates how to integrate mdbreact (material design bootstrap for react) with next.js
2020-12-31 18:46:10 +00:00
JJ Kasper
3a9d18b549
Add isReady field on router (#20628)
Adds an `isReady` field on `next/router` specifying whether the router fields are updated client-side and ready for use. Should only be used inside of `useEffect` methods and not for conditionally rendering on the server.

Closes: https://github.com/vercel/next.js/issues/8259
Closes: https://github.com/vercel/next.js/pull/9370
2020-12-31 16:54:32 +00:00
Tom
bd4eb9ea41
fix mongoose not latest next.js version (#20644) 2020-12-31 11:33:24 -05:00
Joe Haddad
dbe1e626f8
fix(experimental scroll): use sessionStorage instead of history (#20633)
This pull request adjusts our experimental scroll restoration behavior to use `sessionStorage` as opposed to `History#replaceState` to track scroll position.

In addition, **it eliminates a scroll event listener** and only captures when a `pushState` event happens (thereby leaving state that needs snapshotted).

These merely adjusts implementation detail, and is covered by existing tests:
```
test/integration/scroll-back-restoration/
```

---

Fixes #16690
Fixes #17073
Fixes #20486
2020-12-31 16:08:12 +00:00
Lee Robinson
380afbfba2
Add docs on authentication patterns. (#16277)
Building off [this Slack conversation](https://vercel.slack.com/archives/CGD3XGSD7/p1597329727013900), this PR adds a top-level section to the documentation on authentication patterns.

Please provide any and all comments! A few open thoughts I have:

- ~Should this include code snippets from the related providers or stay very high-level? At what point do we delegate to the examples folder?~ Keep things high level and delegate to examples folder 
- ~Should this include any related cards at the bottom?~ Added to the bottom
- ~Should other places in the documentation link back to here?~ Added link from routing
- Should it be a top-level route, or be underneath advanced?
2020-12-31 08:28:11 +00:00
JJ Kasper
fd33c9f7e1
Ensure href is updated for locale domain (#20631)
This ensures we render the locale domain on the `href` when using `next/link` previously the provided `href` was stilling being rendered which differed from the resulting `href` that was navigated to. 

Fixes: https://github.com/vercel/next.js/issues/20612
2020-12-31 08:07:51 +00:00
JJ Kasper
9fc9a6e1e4 v10.0.5-canary.6 2020-12-30 23:30:30 -06:00
Guy Bedford
b7272995b5
feat: upgrade to ncc@0.26.1 (#20627)
This upgrades to the version of ncc with subbundling support.
2020-12-31 00:50:45 +00:00
Greg Rickaby
305b15e089
Update blog starter example (#19698)
* bump dependencies to latest versions

* use tailwindcss class names

* use next/image component

* pass in height & width. update tailwindcss classes

* update tailwindcss classes

* mention tailwindcss 2.0
2020-12-30 19:04:23 -05:00
Prateek Bhatnagar
16e9de3565
Fix: fallback font tag repetition (#20382)
partially fixes #20341

- Makes sure that font fallback does not get repeated for every request.
- Adds a test for the same.
2020-12-30 23:41:33 +00:00
JJ Kasper
5324e8b6ee
Ensure SSG data 404 handles correctly for non-notFound (#20622)
Follow-up to https://github.com/vercel/next.js/pull/20594 this ensures non-notFound SSG data 404s do cause a hard navigation as this signals a new deployment has occurred and a hard navigation will load the new deployment's version of the page. 

Closes: https://github.com/vercel/next.js/issues/20623
2020-12-30 22:35:02 +00:00
Alex Castle
74909ecfd4
Move CSS Preloads to top of head at document render (#18864)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-12-30 17:12:46 -05:00
Joe Haddad
cc0dcf96d5
v10.0.5-canary.5 2020-12-30 16:38:28 -05:00
Joe Haddad
74693810d0
docs: update image docs for consistency (#20621) 2020-12-30 16:33:21 -05:00
Joe Haddad
45b87aa23a
feat(next/image): preload priority images (#20615)
The HTML Living Standard explicitly says `href` should be omitted to prevent the loading of an incorrectly sized image:
https://html.spec.whatwg.org/multipage/semantics.html#attr-link-imagesrcset

![image](https://user-images.githubusercontent.com/616428/103378205-8a013800-4aaf-11eb-9085-10f547263fed.png)

Since it's in the spec, I assume this is valid-enough HTML.

This also dedupes preloads which the old implementation did not.

---

Fixes #18756
x-ref #19118
Fixes #18720
2020-12-30 21:10:28 +00:00
mustafaKamal-fe
4e27e00c30
Update dbConnect.js (#19644)
* Update dbConnect.js

The previous logic was in my opinion prone to errors in situations when different calls to this function from different locations may happen at the same time ( like a race condition  ). If the readyState is anything but not 0, then we must not try to perform a new connection as this may cause consequent connections!

I hope this makes sense

* Update examples/with-mongodb-mongoose/utils/dbConnect.js

* Lint fix and minor changes

Co-authored-by: Luis Alvarez D <luis@vercel.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-12-30 15:18:32 -05:00
Tyler Deitz
ec430ea77d
Fix memory leak in useIntersection (#20407)
This pull request adds an `elements.delete` operation to the `useIntersection`'s cleanup function: `unobserve`.

Without this delete operation, next.js holds onto an unreachable reference of every observed element indefinitely (automatically every Link and Image is observed, so that means every rendered Link and Image element adds to the leak). I found this memory leak when building out an infinite feed in next.js with thousands of Link elements.

The final code block of the `unobserve` function body:

```tsx
  // Destroy observer when there's nothing left to watch:
  if (elements.size === 0) {
    observer.disconnect()
    observers.delete(id)
  }
```

Is effectively unreachable without this delete operation, as the `elements` map will never decrease in size as it is currently. This means that there will always be at least one IntersectionObserver instance in memory if useIntersection has been used once, regardless of if there are currently any components still using the hook.
2020-12-30 20:04:57 +00:00
Joe Haddad
d1c565901e
feat(next/image): reduce byte waste for 3x screens (#20610)
https://blog.twitter.com/engineering/en_us/topics/infrastructure/2019/capping-image-fidelity-on-ultra-high-resolution-devices.html

> This means that most OLED screens that say they are 3x resolution, are actually 3x in the green color, but only 1.5x in the red and blue colors. Showing a 3x resolution image in the app vs a 2x resolution image will be visually the same, though the 3x image takes significantly more data. Even true 3x resolution screens are wasteful as the human eye cannot see that level of detail without something like a magnifying glass.

> ![image](https://user-images.githubusercontent.com/616428/103366340-61b61100-4a90-11eb-9c16-8467f8930247.png)

Even the iPhone doesn't have true 3x DPI!

related: #18756
2020-12-30 18:17:46 +00:00
JJ Kasper
c0ff5ef2c4 v10.0.5-canary.4 2020-12-30 10:26:25 -06:00
Joe Haddad
7646921911
fix(router): consistent scroll behavior for Link/Router#push (#20606)
This pull request makes `Router#push` and `Router#replace` function identically to `<Link />`, i.e. reset scroll when the new render is complete.

Users can opt out of this new behavior via:
```tsx
const path = '/my-page'
router.push(path, path, { scroll: false })
```

---

Fixes #3249
2020-12-30 16:10:59 +00:00
Joe Haddad
3246274dfd
fix(build): require test files be full name or extension (#20605)
Fixes #19935
2020-12-30 15:49:37 +00:00
Lee Robinson
a03f1f3847
Add version history for API changes to documentation. (#20604)
Closes https://github.com/vercel/next.js/issues/20036.
2020-12-30 15:06:34 +00:00
JJ Kasper
75509164ab
Ensure domain locales are redirected client-side (#20562)
This ensures we detect domain specific locales and redirect them client-side. Tests have been added in the `i18n` suite to ensure the domain redirect is applied correctly during a client-side navigation

Fixes: https://github.com/vercel/next.js/issues/19174
2020-12-30 06:44:07 +00:00
JJ Kasper
97e9d54f2e
Ensure index basePath is detected correctly (#20596)
This ensures we detect the `basePath` correctly for the index `basePath` route when either a `hash` or a `query` are present in the provided path. This also adds this specific test to our basePath test suite. 

Fixes: https://github.com/vercel/next.js/issues/19294
Fixes: https://github.com/vercel/next.js/issues/19437
Closes: https://github.com/vercel/next.js/pull/19444
2020-12-30 05:37:26 +00:00
JJ Kasper
949657675e
Refactor GS(S)P notFound client-side handling (#20594)
This refactors to instead of throwing a specific error when a SSG data route 404s, we return it through props and render the 404 outside of the error handling flow. No additional tests have been added as existing tests should cover this. 

Closes: https://github.com/vercel/next.js/issues/19243
2020-12-30 05:17:10 +00:00