Skip to content

[pull] canary from vercel:canary #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 11, 2025
Merged

[pull] canary from vercel:canary #51

merged 10 commits into from
Apr 11, 2025

Conversation

pull[bot]
Copy link

@pull pull bot commented Apr 11, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.1)

Can you help keep this open source service alive? 💖 Please sponsor : )

mischnic and others added 10 commits April 10, 2025 21:27
Only resolve/bundle `new Worker()` calls with a `new URL("..", import.meta.url)` argument, and ignore anything else (just like Webpack).

Closes #74621
Closes PACK-4312
…y api (#78032)

[HashMap’s raw_entry api](rust-lang/rust#56167), an unstable nightly feature, was removed from the Rust compiler entirely.

This migrates us to use the equivalent API in HashBrown’s HashMap.
Show a redbox when specifying a non-existent plugin instead of crashing Turbopack

The error location could be better, but we don't actually know the line/column here

![Bildschirmfoto 2025-04-10 um 08 56 39](https://github.com/user-attachments/assets/c816704d-b5c6-48bc-8471-92082abe5614)
The conventional wisdom of Node.js and other runtimes is to treat
unhandled errors as fatal and exit the process.

But Next.js is not a generic JS runtime — it's a specialized runtime for
React Server Components.

Many unhandled rejections are due to the late-awaiting pattern for
prefetching data. In Next.js it's OK to call an async function without
immediately awaiting it, to start the request as soon as possible
without blocking unncessarily on the result. These can end up triggering
an "unhandledRejection" if it later turns out that the data is not
needed to render the page. Example:

```js
const promise = fetchData()
const shouldShow = await checkCondition()
if (shouldShow) {
  return <Component promise={promise} />
}
```

In this example, `fetchData` is called immediately to start the request
as soon as possible, but if `shouldShow` is false, then it will be
discarded without unwrapping its result. If it errors, it will trigger
an "unhandledRejection" event.

Ideally, we would suppress these rejections completely without warning,
because we don't consider them real errors. But regardless of whether we
do or don't warn, we definitely shouldn't crash the entire process.

Even a "legit" unhandled error unrelated to prefetching shouldn't
prevent the rest of the page from rendering.

So, we intentionally override the default error handling behavior of the
outer JS runtime to be more forgiving.

---

This was already the behavior of Next.js for self-hosted deployments —
i.e. `next start` — but the rejection listeners were being installed in
a code path that does not run for other deployment targets, like Vercel.

So what this PR does is move the rejection handling code to a path
that's common to all deployement targets.

One possibly controversial aspect that is new to this PR is that it
removes all existing "unhandledRejection" handlers, before Next.js
installs its own. This is to override any handlers that exit the
process. Generally we think this is fine because it's unlikely that
Next.js will be deployed in such a way that it's sharing a process with
non-Next.js applications; however, if we get feedback to the contrary,
we'll figure out a strategy to deal with it.
Attempts to reland parts of #77054.
    
- Removed `#![feature(extract_if)]`
- Removed `#![feature(hash_extract_if)]`
- Removed no-op `#[must_use]`
- Addressed new clippy violations
    
Test Plan:
    
- [ ] Manual build and deploy
…config (#77905)

When using both pages & app routers, during `next dev` and `next start`,
if a function triggers a 404 error, we serve the app router not found
page rather than the pages router one.

When paired with the `i18n` configuration in `next.config`, the Next.js
builder ignores the app router 404 and bundles the localized pages
router 404 pages with the deployed functions. This leads to a 500 error,
and is fixed in vercel/vercel#13222

However, to match the dev/start handling, we also need to update the
`pages-manifest` so the builder knows to resolve `/404.html` and not the
pages router variant when deployed.

Fixes NEXT-4045

Validation:
[vtest314-e2e-tests-bkc89ab40-ztanner.vercel.app/app-dir/foo](https://vtest314-e2e-tests-bkc89ab40-ztanner.vercel.app/app-dir/foo)
… from crashing (#78042)

This broadens the scope of the `removeUnhandledRejectionListeners` flag
to also remove `uncaughtException` listeners.

The motivation is the same: uncaught exceptions in one part of the page
should not prevent the rest of the page from rendering.

See #77997 for more context.

I renamed the experimental flag to
`removeUncaughtErrorAndRejectionListeners` to better reflect increased
scope but the name isn't really that important since at this stage we
just need to try out the behavior; it isn't documented anywhere.
@pull pull bot added the ⤵️ pull label Apr 11, 2025
@pull pull bot merged commit 3e24bdc into code:canary Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants