Closed stefanprobst closed 8 months ago
You're using notFound API from next/navigation
in i18n.ts
, seems like that file is also going to be used for og image. But og image are basically the app route where we're using react-server
condition, and should return a 404 response for responding "not found" instead of call notFound
() API. If you comment out that API it works well.
thanks for investigating! to clarify, v14.1.0 not showing that error message was actually incorrect? (also, why the difference between "edge" and "node" runtime?)
also not sure what you are suggesting to comment out -- when removing notFound()
(like here) is still see the same error message.
Running into the same error as well – looks like it's an issue with the edge runtime + useContext
hook
Not blocking any builds, but it keeps showing up in the build logs + terminal for every HMR 😅
Same error for us. If we have a page with edge runtime, we get the following error:
../../node_modules/next/dist/esm/client/components/navigation.js
Attempted import error: 'useContext' is not exported from 'react' (imported as 'useContext').
Import trace for requested module:
../../node_modules/next/dist/esm/client/components/navigation.js
../../node_modules/next/dist/esm/api/navigation.js
../../node_modules/next-intl/dist/esm/server/react-server/RequestLocale.js
../../node_modules/next-intl/dist/esm/server.react-server.js
./app/[locale]/layout.tsx
../../node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2F%5Blocale%5D%2Ftransactions%2Fdeposits%2Fpage&page=%2F%5Blocale%5D%2Ftransactions%2Fdeposits%2Fpage&pagePath=private-next-app-dir%2F%5Blocale%5D%2Ftransactions%2Fdeposits%2Fpage.tsx&appDir=%2FUsers%2Fsaikoubarry%2FDocuments%2FGreenIsland%2Fstarcasino-portal-client%2Fapps%2Fstarcasinodice%2Fapp&appPaths=%2F%5Blocale%5D%2Ftransactions%2Fdeposits%2Fpage&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D!./app/[locale]/transactions/deposits/page.tsx?__next_edge_ssr_entry__
In the page we doesn't use the notFound()
api
import { Metadata } from 'next';
import { AppRoutes } from '@org/constants';
import { ComponentA } from './_components/ComponentA';
import { getSession, withPageAuthRequired } from '@auth0/nextjs-auth0/edge';
export const runtime = 'edge';
export default withPageAuthRequired(
async function Page({
searchParams,
}: {
searchParams: { [key: string]: string | string[] | undefined };
}) {
const session = await getSession();
const queries = {};
return <ComponentA {...queries} userId={session.user.userId} />;
},
{
returnTo({ params }) {
return `${params.locale === 'en' ? '' : `/${params.locale}`}/${AppRoutes.PageA}`;
},
}
);
Yea looks like previously we didn't alias the correct react bundle, and after we got the correct react bundle on server components and app routes side, then we can analysis the correct exports usage of react. next/navigation
needs to be separated into 2 parts, the one used only on server side shouldn't need to touch the imports of React. Got a PR to fix it
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Link to the code that reproduces this issue
https://github.com/stefanprobst/issue-next-browserslist
To Reproduce
pnpm install
pnpm run build
Current vs. Expected behavior
next build
does complete)Provide environment information
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
No response
NEXT-2519