Skip to content
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

Refactor notFound and introduce Forbidden #1

Open
wants to merge 433 commits into
base: canary
Choose a base branch
from

Conversation

panteliselef
Copy link
Owner

No description provided.

@panteliselef panteliselef force-pushed the elef/introduce-error-builder branch 2 times, most recently from ae07013 to c3baf8b Compare May 20, 2024 18:49
@panteliselef panteliselef force-pushed the elef/introduce-error-builder branch from 3fd8a99 to ebadaa5 Compare June 19, 2024 09:14
unstubbable and others added 27 commits July 9, 2024 12:26
- The array nesting was most likely done accidentally in vercel#42482.
- The wording 'parameters' is vestigial from when those were actually
query params.
- Some header consts were missing the `_HEADER` suffix.
Currently when the test suite gets stuck it can lead to a job running
for 6 hours before being cancelled. E.g.:
https://github.com/vercel/next.js/actions/runs/9841535415/job/27168973064

This PR mirrors the other workflows that use `run-tests.js` adding the
same timeout as those workflows.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
This auto-generated PR updates the production integration test manifest
used when testing Turbopack.

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
> Note: port of vercel#57656

## What?

This PR initiated support of `next.config.ts`.

Follow ups:

- update docs
([x-ref](vercel@2ea9b6e))
- update cna ts templates
([x-ref](vercel@80e6740))

## Why?

> Next.js provides a TypeScript-first development experience for
building your React application.

This PR can resolve the two main needs:

1. Import TS files to the config.
2. Conduct a type check directly by importing `type` instead of JSDoc.

x-ref: vercel#5318 vercel#35969 vercel#44632 vercel#50121 vercel#50126

## How?

### Goals

- [x] [do not
bundle](vercel#57656 (comment))
- [x] [minimum fs
operations](vercel#63051 (comment))
- [x] zero restrictions

Used `require.extensions` hooks to transpile the imported files on the
fly.

To reduce I/O operation on disk, used custom `module.exports` to require
directly from a transpiled code string.

## Expected

> Added tests for the cases below:

- [x] export default
- [x] export config `as default`
- [x] [config as an async
function](https://nextjs.org/docs/app/api-reference/next-config-js)
- [x] use Node.js modules (fs, path, etc.)
- [x] HMR on config change
- [x] throw when type error
- [x] turbopack

### Importing Files

- [x] nested imports (config -> A -> B)
- [x] import alias (tsconfig baseUrl and paths)
- [x] import from `node_modules`
- [x] import `JSON`

#### Extensions

- [x] `.ts`
- [x] `.cts`
- [x] `.mts`
- [x] `.cjs`
- [x] `.mjs`
- [x] `.js` (both ESM and CJS w/o extra change)

---------

Co-authored-by: Donny/강동윤 <kdy1997.dev@gmail.com>
Co-authored-by: Sukka <isukkaw@gmail.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Sam Ko <sam@vercel.com>
Co-authored-by: Ahmed Abdelbaset <A7med3bdulBaset@gmail.com>
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
)

### What?
Adds a whitespace character before seconds output of
`scripts/trace-to-tree.mjs`

### Why?
I was regexing a big output, looking for sources of slowness and failed
to do so because `\ss` would not find anything, whist `\sms` would,
because it printed whitespace before `ms` but not before `s`.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
…ercel#67435)

This PR was originally intended to ensure style/script tags were always
rendered for all visible parallel routes, as before only the "first"
child was rendered, similar to `head`.

However, it caused a regression in PPR navigations, as the pending task
on the `layerAssets` CacheNode meant that the `useDeferredValue` call in
`layout-router` wouldn't be able to immediately switch to the prefetched
RSC payload, as it was blocked by the dynamic response.

Since `rsc` and `layerAssets` are both created by the same thing, this
stack of PRs rewinds some of that work to combine them.

This PR only reverts the previous implementation, and adds a test for
the PPR navigation case that was failing.

**Note: While I've split these PRs out for readability, this should land
with vercel#67436 as this PR by itself does not restore the CSS behavior that
was fixed in the original implementation.**
This updates trace experiment to capture more dependencies in the custom
`fileHashes` field.

---------

Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
…ercel#67164)

Writes out the statistics gathered via vercel/turborepo#8286 to a file.

Stats can be formatted and sorted with jq:

```
jq 'to_entries | sort_by(.value.cache_miss) | reverse | from_entries' <input.json >output.json
```

Output looks something like this (once formatted and sorted):
https://gist.github.com/bgw/4e2df35b9e410bf71fe51ecaffc3c7bf

Without vercel#67165, this requires that SIGINT be sent directly to the
`next-server` process to allow a clean exit:

```
pkill -INT next-server
```

But with vercel#67165, a simple <kbd>ctrl</kbd>+<kbd>c</kbd> works.
During SSR, we walk the component tree and pass and immediately seed the
router cache with the tree.

We also seed the prefetch cache for the initial route with the same tree
data because navigations events will apply the data from the prefetch
cache. The rationale for this is that since we already have the data, we
might as well seed it in the prefetch cache, to save a server round trip
later.

The way we're seeding the cache introduced a bug when PPR is turned on:
PPR expects that each element in `FlightDataPath` is of length 3,
corresponding with: `[PrefetchedTree, SeedData, Head]`. However, we were
seeding it with 4 items: `[Segment, PrefetchedTree, SeedData, Head]`.
When the forked router implementation sees anything other than 3 items,
it reverts back to the pre-PPR behavior, which means the data will be
lazy-fetched during render rather than eagerly in the reducer.

As a result, when navigating back to the page that was seeded during
SSR, it wouldn't immediately apply the static parts to the UI: it'd
block until the dynamic render finished.

This PR also includes a small change to ensure reused tasks don’t
trigger a dynamic request. A navigation test was failing because this PR
fixed a bug that was causing it to hit the non-PPR behavior, which
already handles this correctly.

I've added an explicit test for this in PPR. I've also excluded all of
the `client-cache` tests from PPR, as many of them were already failing
and aren't relevant to PPR, since PPR doesn't currently make use of the
`staleTime`/ cache heuristics that the regular router does.
…l#67608)

This assertion flakes all the time, so I'd say that it it's not actually
checking anything useful. I think it's better to disable this and save
everyone some reruns
We were creating a `next.config.js` file which conflicts with an
existing `next.config.ts` file, since the next config detection wasn't
properly looking at files in the test dir.


[x-ref](https://github.com/vercel/next.js/actions/runs/9862195913/job/27233838936)
)

Somewhat surprisingly this fixes a lot of tests as they check for the
exact logline to determine if compilation was successful 😄

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
…ercel#67601)

This allows us to change the `next.config.js` file before a test with an
already running dev server, without getting connection issues because
the dev server may not have restarted in time for the next test to
trigger requests.
- Skip a test that only applies to webpack as it relies on the chunk
loading
- Updated a test to look for the scheme that works in both Turbopack and
Webpack
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
This auto-generated PR updates the development integration test manifest
used when testing Turbopack.
This auto-generated PR updates the production integration test manifest
used when testing Turbopack.
…l#67611)

This splits out the existing logic for detecting changed/added tests
into a separate util, so it can be leveraged by vercel#67612.

No changes in functionality, aside from replacing informational logs
with `console.log` rather than `console.error` and a tweak to arg
parsing.
Leverages the work from vercel#66445 to
download artifacts for a particular commit SHA, so that it can be passed
to the `test-deploy` script.

This will let us run deploy tests on PRs, ensuring that they're run from
the Next.js on the target branch rather than `canary`.

This waits until `test-new-tests-dev` and `test-new-tests-start`
complete for 2 reasons:
- No reason to waste deploy resources if the changed/added tests don't
even work in dev/start
- It gives time for deploy-tarball to finish

Sample run:
https://github.com/vercel/next.js/actions/runs/9865244781/job/27241944533?pr=67612#step:28:54
This ensures that the route is fulfilled before resolving the promise
used in the test, to make sure we don't proceed until the network
finishes.


[x-ref](https://github.com/vercel/next.js/actions/runs/9865629712/job/27243698469)
### What?

This partially reverts vercel#67222, it's unnecessary to build all parallel
routes and also seems to have a higher overhead than I thought.
## What

This PR introduces a new API `onRequestError` in `instrumentation.js`
convention, which can help you track the errors thrown from pages and
routes on server side.

### API

```ts
type RequestInfo = {
  url: string
  method: string
  headers: Record<string, string | string [] | undefined>
}

type ErrorContext = {
  routerKind: 'Pages Router' | 'App Router'
  routePath: string
  routeType: 'render' | 'route' | 'middleware'
}

export function onRequestError(error: unknown, request: RequestInfo, errorContext: ErrorContext) {
}
```

This experimental feature is now scoped behind an experimental env var
`__NEXT_EXPERIMENTAL_INSTRUMENTATION` now. You need to enable to use it
before the feature is fully ready off from experimental.

## Why

The purpose is to provide a way to track the server errors from Next.js
much easier, especially when users're uing an o11y provider such as
sentry/datadog/newrelic etc. to monitor server side exceptions. There're
different runtime (Node.js or Edge) and different type of routes (App
Router pages/API routes, Pages Router pages/API routes, middleware) that
makes the error tracking story more complex. This API will be an
universal way to get all the errors.

The reason of providing the related arguments like request info and
error context is aimed to provide more insights about associated
request, also the context about Next.js framework itself, like which
feature is throwing the error.
kdy1 and others added 26 commits July 25, 2024 08:24
…el#68142)

### What?

Use `[]` instead of `()` for call stack.

### Why?

vercel#68056 (comment)

### How?
…#67948)

ExternalCjsModulesResolvePlugin was originally disabled for requests
inside node_modules (e.g. from inside `cacheable-request` to `keyv`) by
@sokra in vercel/turborepo#3736.
But it seems that we do want this to happen

In the `ExternalPredicate::AllExcept` case, requests inside node_modules
are still ignored. Otherwise
`next/dist/compiled/next-server/pages.runtime.dev.js` was marked as
external and failed many tests

With that fixed, add `keyv` so that `got` can be imported.

Fixes vercel#67282
Fixes PACK-3139
…cel#68123)

### What

Fix handling of user-provided refs in `Image` and `Link` to support
[refs with cleanup
functions](https://react.dev/blog/2024/04/25/react-19#cleanup-functions-for-refs)
(new in React 19)

### Why

React 19 allows [a new form of callback
ref](https://react.dev/blog/2024/04/25/react-19#cleanup-functions-for-refs),
which returns a cleanup function:
```ts
(element: HTMLElement) => {
  console.log('hi ref!')
  return () => {
    console.log('bye ref!')
  }
}
```
Unfortunately, this can be a breaking change for code that attempts to
combine ("merge") multiple callback refs into one. With old-style
callback refs, we never had to care about the return values. But with
the introduction of cleanup functions, ignoring the return value can
lead to logic errors (because the cleanup will never be called)!

This was the case for `Image` and `Link`, both of which attempt to
combine user-provided refs with their own callback refs, but were
ignoring the return values, so they'd break if the user's ref returned a
cleanup function.

### How

This PR introduces a `useMergedRef(refA, refB)` hook that combines all
forms of refs correctly (thanks @eps1lon for sketching it out!) and
refactors Image and Link to use it.
## Why?

Fixing `other` → `order` typo.

- x-ref:
vercel#67691 (comment)
This PR updates the nested-components example to use the App Router.
Here are the changes that have been made:

Renamed the "pages" folder to "app" folder.
Updated the file index.tsx to page.tsx to align with App Router.
Added the layout.tsx file as part of the App Router.
Updated the components folder to align with App Router and made
components folder private.
Updated package.json to use the latest version.

cc: @samcx

---------

Co-authored-by: ShruthiKathula <147117812+ShruthiKathula@users.noreply.github.com>
Co-authored-by: samcx <sam@vercel.com>
### What?

Fix duplicate "the the" in production checklist docs
vercel#66339)

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

fixes vercel#64364 

As noted in the bug, the `dataLayer` parameter to the GoogleTagManager
third-party component should be an object (which gets passed to
`JSON.stringify()` at
https://github.com/vercel/next.js/blob/canary/packages/third-parties/src/google/gtm.tsx#L43),
and not an array of strings.

(I'm speculating a bit, but assuming that the original intent was that
an object could be serialized and passed to the component, but then the
call to stringify was added to the component as well.)

I'm not thrilled about duplicating the JSONValue type, which also exists
in `packages/next/src/server/config-shared.ts`, but wasn't sure whether
it would be preferred to export from there -- this doesn't feel like
it's likely to be an issue, but I'm perfectly happy to change

---------

Co-authored-by: Sam Ko <sam@vercel.com>
It seems that this now [works in Azure](https://dev.azure.com/nextjs/next.js/_build/results?buildId=92732&view=logs&j=14d0eb3f-bc66-5450-3353-28256327ad6c&t=7e988112-57f9-5e14-1c8c-05f6c2b0ea47), so we don't need to differentiate based on the platform anymore. Using the shared `createNextInstall` is a requirement for vercel#68084. To make this work, we need to also fix an accidental breakage of `hasIsolatedTests` from vercel#53406.
These tests were disabled as part of vercel#65845, probably due to mismatching peer dependency errors. This has been resolved in the meantime.

As part of this PR we're also fixing how the tests are installing Next.js in preparation for running `create-next-app`:

The `run-tests.js` script already calls `createNextInstall` and does all the heavy lifting. Calling it again in the `create-next-app` integration tests is wasteful.

In addition, the built `next` tarball is exposed by `run-tests.js` via the `NEXT_TEST_PKG_PATHS` env variable. We need to provide the filename of the tgz as `NEXT_PRIVATE_TEST_VERSION` so that `create-next-app` uses it in the generated `package.json` as the `next` dependency "version".

With the previous approach, the installation was pointing `next` at the `installDir`, which has its own version of React installed. This created runtime errors (`TypeError: Cannot read properties of null (reading 'useContext')`) when running `next dev` in a pages project that was created with `create-next-app`.

Some of the tests were even downloading a published `canary` version of `next` instead of using the version from the current branch. This has been fixed as well.
> **YES,**
> **WE**
> **CNA.**

This is a small improvement for power users that run `create-next-app` frequently, using the same preferences. By specifying the `--yes` option along with the project name, they won't be prompted for any preferences. Instead, the previously used preferences are automatically chosen, using the defaults as fallback.
… cleanup function" (vercel#68176)

Seems this is causing us to hit the following error our vercel-site

```sh
 ReferenceError: navigator is not defined
vercel-site:build:     at s (/vercel/path0/apps/vercel-site/.next/server/chunks-EDOwHfQ0FCxDTUqmP-83_/65787.js:161:168406)
vercel-site:build:     at u (/vercel/path0/apps/vercel-site/.next/server/chunks-EDOwHfQ0FCxDTUqmP-83_/65787.js:50:154810)
```

Reverts vercel#68123
Reverts vercel#67929

This is causing deployment test failures.
[x-ref](https://github.com/vercel/next.js/actions/runs/10103034192/job/27940614533#step:27:178)

Validated that it passes locally. For reviewers, you can validate by
comparing these 2 URLs:

<details>

<summary>Not Working</summary>


https://vtest314-e2e-tests-6j3mwq9jg-ztanner.vercel.app/metadata-error-with-boundary

</details>

<details>

<summary>Working</summary>


https://vtest314-e2e-tests-ihcxlytpd-ztanner.vercel.app/metadata-error-with-boundary

</details>
# Conflicts:
#	packages/next/src/client/components/app-router.tsx
#	packages/next/src/client/components/is-next-router-error.ts
#	packages/next/src/client/components/layout-router.tsx
#	packages/next/src/client/components/ui-error-boundary.tsx
#	packages/next/src/export/helpers/is-navigation-signal-error.ts
#	packages/next/src/server/app-render/app-render.tsx
#	packages/next/src/server/app-render/create-component-tree.tsx
…68176) (vercel#68199)

This reverts commit 7f677d1. Cannot reproduce the `vercel-site` failure
cited in vercel#68176, and there's no apparent reason why this PR would cause
that
A proper fix to vercel#66448.

The root cause of the issue is that Next.js gets SWC bindings list from
`package.json`'s `optionalDependencies` when patching the lockfile.
Recently Next.js added `sharp` to the `optionalDependencies`, which
causes `sharp` to be wrongly treated as Next.js SWC bindings when
matching versions (hence the `undefined`).

The PR adds a filter after reading `optionalDependencies`.

cc @huozhi @eps1lon

Co-authored-by: JJ Kasper <jj@jjsweb.site>
### What?

`ImageResponse` merges default headers and developer-provided headers
incorrectly. The original implementation uses an object-based,
case-sensitive merging strategy, which results in developer-provided
header values being appended after the default header values by the
`Response` (or `Headers`) constructor.

### Why?

`ImageResponse` is used to generate image dynamically. Sometimes the
scenario would be the following. Given a URL without any timestamp, the
developer wants to generate an image depending on a mutable state. For
example, a profile image URL that is to be embedded on blogs by the end
user. In that case, the URL should be stable, and the `max-age` of the
image should be kept short enough because the end user might change
their profile. If the developer passes in a `Cache-Control` header with
any object key other than the fully lower-cased `cache-control`, the
developer's `Cache-Control` value gets **appended** after the default
`Cache-Control` value.

### How?

This PR fixes this by respecting developer-provided headers and
overwriting default ones if the developer has explicitly specified one.

Fixes vercel#67641

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Lee Robinson <me@leerob.io>
Bump @vercel/ncc to 0.38.1

I have changed the `"skipLibCheck": true` setting in tsconfig because
otherwise the `tar` library gives a type error inside "node_modules" I
made an issues in their repository but the maintainer did not give any
conclusive solution:
[issues](isaacs/node-tar#419)

Is there a problem I haven't seen by disabling this?

---------

Co-authored-by: torresgol10.it <torresgol10.itd@gmail.com>
Co-authored-by: samcx <sam@vercel.com>
@panteliselef panteliselef force-pushed the elef/introduce-error-builder branch from 16828cf to 0b8a76f Compare July 28, 2024 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.