-
Notifications
You must be signed in to change notification settings - Fork 91
fix: next 16 adjustments #3155
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 16 adjustments #3155
Conversation
…ore clicking links
`server/chunks/**/*`, | ||
`server/edge-chunks/**/*`, | ||
`server/edge/chunks/**/*`, | ||
`server/edge/**/*`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is for:
fix: bundle edge-runtime assets for turbopack builds
we do need to bundle edge/assets
at least (it's needed for @vercel/og
/ next/og
) support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if it would be preferred to add server/edge/assets/**/*
to the list instead of editing the server/edge/chunks
entry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debugging this took quite a while as original error was looking like so
stderr | tests/integration/wasm.test.ts > 'wasm-src' > should work in app route
⨯ Error: failed to pipe response
at ignore-listed frames {
[cause]: TypeError: fetch failed
at ignore-listed frames {
[cause]: Error: invalid method
at ignore-listed frames
}
}
It took peeling few layers to understand what's wrong and few dead ends along the way. Generally all those files are recomended to be bundled. In initial PR for turbopack support I also attempted to be conservative with what we bundle and this is how we ended up with just edge/chunks
. I think this shown me that there are just cases that I don't know about and that debugging them is painful.
This of course is tradeoff between supporting cases we potentially don't know about today (other than @vercel/og
case) vs potential of getting into lambda too large cases. At least latter ones we have some ideas to make easier to debug if we learn that we start bundling too much
if (existsSync(rootSrcDir) && ctx.standaloneRootDir !== ctx.standaloneDir) { | ||
promises.push( | ||
cp(rootSrcDir, rootDestDir, { recursive: true, verbatimSymlinks: true }).then(() => | ||
cp(rootSrcDir, rootDestDir, { recursive: true, verbatimSymlinks: true, filter }).then(() => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is for:
fix: exclude musl binaries from function bundle when building on Netlify with pnpm monorepos
previous fix only applied to non-monorepos - this applies it in morepos as well
📊 Package size report -0%↓
Unchanged files
🤖 This report was automatically generated by pkg-size-action |
expect(response?.status()).toBe(404) | ||
|
||
expect(await page.textContent('h1')).toBe('404') | ||
await expect(page.locator('h1')).toHaveText('404') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shared for all page.textContent
replacements - it's discouraged and deprecated - see https://playwright.dev/docs/api/class-page#page-text-content
I thought this was causing problems in at least some of our tests. This ended up not being problem, but as I already migrated away from it, might as well keep it in this PR I think
// wait for hydration to finish before doing client navigation | ||
await expect(page.getByTestId('hydration')).toHaveText('hydrated', { | ||
timeout: 10_000, | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seemed to be a problem where test was clicking links too fast (before hydration happened) so the rest of the test expecting next/link
navigation was being very flaky. I did add useEffect
in fixture to allow tests to wait for hydration to happen here
Thumbs.db | ||
|
||
.nx/cache | ||
.nx/workspace-data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NX dependencies in nx fixture had to be updated to work with next@16, I did run upgrade migration and as a result there were some additional changes applied to fixture
// on failures we don't delete the deploy, but we do cleanup the fixture from filesystem in CI | ||
if (process.env.CI) { | ||
return cleanup(isolatedFixtureRoot, undefined) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not strictly needed now, but on repeated failures github action runners were running out of disk space because those isoloated fixtures were not being deleted
b5083d6
to
db8b606
Compare
export const EDGE_MIDDLEWARE_FUNCTION_NAME = '___netlify-edge-handler-middleware' | ||
export const EDGE_MIDDLEWARE_SRC_FUNCTION_NAME = '___netlify-edge-handler-src-middleware' | ||
// Turbopack has different output than webpack | ||
export const EDGE_MIDDLEWARE_SRC_FUNCTION_NAME = hasDefaultTurbopackBuilds() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turbopack changes the name of the edge handler? Or is this more about the next.js version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turbopack changes the name of the edge handler?
Indirectly. We use name
from middleware-manifest.json
to produce our handler name -
opennextjs-netlify/src/build/functions/edge.ts
Lines 309 to 310 in 4aaeb79
const getHandlerName = ({ name }: Pick<EdgeMiddlewareDefinition, 'name'>): string => | |
`${EDGE_HANDLER_NAME}-${name.replace(/\W/g, '-')}` |
In webpack builds:
- if
middleware.(js|ts)
file is in root of workspace - the name in manifest will bemiddleware
- if
middleware.(js|ts)
file is insrc
directory of workspace - the name in manifest will besrc/middleware
In turbopack the name in manifest is always middleware
regardless if file is in root or in src
Description
Next.js canary switched builds to turbopack by default, which exposed some quirks that were not noticed in hello-world type of test fixture we used before. This PR applies some fixes, but most of it are test adjustments
Override below is attempt to create 2 entries in changelog, as there are 2 separate fixes in this PR
BEGIN_COMMIT_OVERRIDE
fix: bundle edge-runtime assets for turbopack builds
fix: exclude
musl
binaries from function bundle when building on Netlify withpnpm
monoreposEND_COMMIT_OVERRIDE