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

fix next/font crash in CNA-generated apps #69784

Merged
merged 3 commits into from
Sep 9, 2024

Conversation

lubieowoce
Copy link
Member

@lubieowoce lubieowoce commented Sep 6, 2024

@ijjk ijjk added create-next-app Related to our CLI tool for quickly starting a new Next.js application. created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation. examples Issue/PR related to examples Font (next/font) Related to Next.js Font Optimization. tests type: next labels Sep 6, 2024
@lubieowoce lubieowoce changed the base branch from canary to 14-2-1 September 6, 2024 12:24
@lubieowoce lubieowoce force-pushed the backport/14.2.x/cna-font-crash-fix branch from 6be9ecf to e551f35 Compare September 6, 2024 12:26
@ijjk
Copy link
Member

ijjk commented Sep 6, 2024

Failing test suites

Commit: 0b89af0

pnpm test-start test/production/app-dir-edge-runtime-with-wasm/index.test.ts

  • app-dir edge runtime with wasm > should have built
Expand output

● app-dir edge runtime with wasm › should have built

Command failed with exit code 1 (EPERM): pnpm install --strict-peer-dependencies=false --no-frozen-lockfile --config.cacheDir=/tmp

  25 |   }
  26 |
> 27 |   await execa('pnpm', args, {
     |   ^
  28 |     cwd,
  29 |     stdio: ['ignore', 'inherit', 'inherit'],
  30 |     env: process.env,

  at makeError (../node_modules/.pnpm/execa@2.0.3/node_modules/execa/lib/error.js:58:11)
  at handlePromise (../node_modules/.pnpm/execa@2.0.3/node_modules/execa/index.js:112:26)
  at installDependencies (lib/create-next-install.js:27:3)
  at Span.traceAsyncFn (../packages/next/src/trace/trace.ts:141:14)
  at lib/create-next-install.js:168:9
  at Span.traceAsyncFn (../packages/next/src/trace/trace.ts:141:14)
  at createNextInstall (lib/create-next-install.js:45:10)
  at lib/next-modes/base.ts:214:36
  at Span.traceAsyncFn (../packages/next/src/trace/trace.ts:141:14)
  at NextStartInstance.createTestDir (lib/next-modes/base.ts:147:5)
  at NextStartInstance.setup (lib/next-modes/next-start.ts:22:5)
  at lib/e2e-utils.ts:201:7
  at Span.traceAsyncFn (../packages/next/src/trace/trace.ts:141:14)
  at createNext (lib/e2e-utils.ts:166:12)
  at Object.<anonymous> (production/app-dir-edge-runtime-with-wasm/index.test.ts:44:12)

● Test suite failed to run

TypeError: Cannot read properties of undefined (reading 'destroy')

  50 |     })
  51 |   })
> 52 |   afterAll(() => next.destroy())
     |                       ^
  53 |
  54 |   it('should have built', async () => {
  55 |     const html = await renderViaHTTP(next.url, '/')

  at Object.destroy (production/app-dir-edge-runtime-with-wasm/index.test.ts:52:23)

Read more about building and testing Next.js in contributing.md.

pnpm test-start test/production/middleware-typescript/test/index.test.ts

  • middleware-typescript > should have built and started
Expand output

● middleware-typescript › should have built and started

next build failed with code/signal 1

  90 |           if (code || signal)
  91 |             reject(
> 92 |               new Error(`next build failed with code/signal ${code || signal}`)
     |               ^
  93 |             )
  94 |           else resolve()
  95 |         })

  at ChildProcess.<anonymous> (lib/next-modes/next-start.ts:92:15)

Read more about building and testing Next.js in contributing.md.

@ijjk
Copy link
Member

ijjk commented Sep 6, 2024

Stats from current PR

Default Build (Increase detected ⚠️)
General
vercel/next.js 14-2-1 vercel/next.js backport/14.2.x/cna-font-crash-fix Change
buildDuration 18.2s 16.1s N/A
buildDurationCached 8.4s 7.4s N/A
nodeModulesSize 200 MB 200 MB
nextStartRea..uration (ms) 417ms 415ms N/A
Client Bundles (main, webpack)
vercel/next.js 14-2-1 vercel/next.js backport/14.2.x/cna-font-crash-fix Change
1103-HASH.js gzip 31.6 kB 31.6 kB N/A
1a9f679d-HASH.js gzip 53.7 kB 53.7 kB N/A
335-HASH.js gzip 5.05 kB 5.05 kB
7953.HASH.js gzip 181 B 181 B
framework-HASH.js gzip 44.9 kB 44.9 kB
main-app-HASH.js gzip 245 B 244 B N/A
main-HASH.js gzip 32.2 kB 32.2 kB N/A
webpack-HASH.js gzip 1.68 kB 1.68 kB N/A
Overall change 50.1 kB 50.1 kB
Legacy Client Bundles (polyfills)
vercel/next.js 14-2-1 vercel/next.js backport/14.2.x/cna-font-crash-fix Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js 14-2-1 vercel/next.js backport/14.2.x/cna-font-crash-fix Change
_app-HASH.js gzip 195 B 197 B N/A
_error-HASH.js gzip 184 B 184 B
amp-HASH.js gzip 501 B 506 B N/A
css-HASH.js gzip 323 B 324 B N/A
dynamic-HASH.js gzip 1.82 kB 1.82 kB N/A
edge-ssr-HASH.js gzip 259 B 258 B N/A
head-HASH.js gzip 350 B 352 B N/A
hooks-HASH.js gzip 372 B 371 B N/A
image-HASH.js gzip 4.23 kB 4.23 kB
index-HASH.js gzip 259 B 258 B N/A
link-HASH.js gzip 2.68 kB 2.68 kB N/A
routerDirect..HASH.js gzip 316 B 315 B N/A
script-HASH.js gzip 387 B 387 B
withRouter-HASH.js gzip 311 B 310 B N/A
1afbb74e6ecf..834.css gzip 106 B 106 B
Overall change 4.9 kB 4.9 kB
Client Build Manifests
vercel/next.js 14-2-1 vercel/next.js backport/14.2.x/cna-font-crash-fix Change
_buildManifest.js gzip 483 B 483 B
Overall change 483 B 483 B
Rendered Page Sizes
vercel/next.js 14-2-1 vercel/next.js backport/14.2.x/cna-font-crash-fix Change
index.html gzip 529 B 528 B N/A
link.html gzip 543 B 540 B N/A
withRouter.html gzip 524 B 523 B N/A
Overall change 0 B 0 B
Edge SSR bundle Size
vercel/next.js 14-2-1 vercel/next.js backport/14.2.x/cna-font-crash-fix Change
edge-ssr.js gzip 95.4 kB 95.4 kB
page.js gzip 3.06 kB 3.06 kB N/A
Overall change 95.4 kB 95.4 kB
Middleware size
vercel/next.js 14-2-1 vercel/next.js backport/14.2.x/cna-font-crash-fix Change
middleware-b..fest.js gzip 660 B 659 B N/A
middleware-r..fest.js gzip 156 B 156 B
middleware.js gzip 25.5 kB 25.5 kB N/A
edge-runtime..pack.js gzip 839 B 839 B
Overall change 995 B 995 B
Next Runtimes
vercel/next.js 14-2-1 vercel/next.js backport/14.2.x/cna-font-crash-fix Change
app-page-exp...dev.js gzip 171 kB 171 kB
app-page-exp..prod.js gzip 98 kB 98 kB
app-page-tur..prod.js gzip 99.8 kB 99.8 kB
app-page-tur..prod.js gzip 94 kB 94 kB
app-page.run...dev.js gzip 145 kB 145 kB
app-page.run..prod.js gzip 92.5 kB 92.5 kB
app-route-ex...dev.js gzip 22 kB 22 kB
app-route-ex..prod.js gzip 15.4 kB 15.4 kB
app-route-tu..prod.js gzip 15.4 kB 15.4 kB
app-route-tu..prod.js gzip 15.2 kB 15.2 kB
app-route.ru...dev.js gzip 21.7 kB 21.7 kB
app-route.ru..prod.js gzip 15.2 kB 15.2 kB
pages-api-tu..prod.js gzip 9.58 kB 9.58 kB
pages-api.ru...dev.js gzip 9.85 kB 9.85 kB
pages-api.ru..prod.js gzip 9.57 kB 9.57 kB
pages-turbo...prod.js gzip 22.5 kB 22.5 kB
pages.runtim...dev.js gzip 23.2 kB 23.2 kB
pages.runtim..prod.js gzip 22.5 kB 22.5 kB
server.runti..prod.js gzip 51.5 kB 51.5 kB
Overall change 954 kB 954 kB
build cache Overall increase ⚠️
vercel/next.js 14-2-1 vercel/next.js backport/14.2.x/cna-font-crash-fix Change
0.pack gzip 1.61 MB 1.61 MB ⚠️ +1.18 kB
index.pack gzip 112 kB 113 kB ⚠️ +517 B
Overall change 1.72 MB 1.72 MB ⚠️ +1.7 kB
Diff details
Diff for edge-ssr.js

Diff too large to display

Commit: 0b89af0

@lubieowoce lubieowoce force-pushed the backport/14.2.x/cna-font-crash-fix branch 2 times, most recently from 632095e to 7ab2d47 Compare September 7, 2024 12:48
@ztanner ztanner force-pushed the backport/14.2.x/cna-font-crash-fix branch from 7ab2d47 to 0b89af0 Compare September 9, 2024 16:13
@ztanner ztanner marked this pull request as ready for review September 9, 2024 17:26
lubieowoce and others added 3 commits September 9, 2024 19:53
this reverts the change from 564b620
…9806)

There's code that uses `glob` to find all template files and replaces
the default import alias with whatever is specified during CNA. This
does so without excluding fonts, and so we're unintentionally corrupting
these `woff` files.

This wasn't a problem in previous versions because we didn't use
`localFont` in the default template, just `Inter`. The files were
technically still being corrupted it just never manifested unless you
went to actually use them.

This is a quick fix to introduce minimal changes but ideally in a
follow-up we should figure out a better solution for replacing aliases,
ie by using an allowlist rather than an exclude list.

h/t to @lubieowoce for the thorough test cases

Fixes #69748

---------

Co-authored-by: Janka Uryga <lolzatu2@gmail.com>
@lubieowoce lubieowoce force-pushed the backport/14.2.x/cna-font-crash-fix branch from 0b89af0 to 4bd3849 Compare September 9, 2024 17:53
@lubieowoce lubieowoce merged commit 4bd3849 into 14-2-1 Sep 9, 2024
48 of 57 checks passed
@lubieowoce lubieowoce deleted the backport/14.2.x/cna-font-crash-fix branch September 9, 2024 17:55
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
create-next-app Related to our CLI tool for quickly starting a new Next.js application. created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation. examples Issue/PR related to examples Font (next/font) Related to Next.js Font Optimization. locked tests type: next
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants