-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
Next.js build error when using Edge Runtime #36574
Comments
@AjoVarghese I'm afraid there isn't enough info for us to look into this, would you mind providing a minimal reproduction? You can fork this template: https://mui.com/r/issue-template-latest PS: Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve |
Since the issue is missing key information and has been inactive for 7 days, it has been automatically closed. If you wish to see the issue reopened, please provide the missing information. |
i have the same error :/ |
This comment was marked as off-topic.
This comment was marked as off-topic.
I have the same issue. However, in my case, it's not possible to replicate that in codesandbox because the error seems to only appear on NextJS, using The minimum repro step would include
import ThemeRegistry from "./ThemeRegistry";
export default function RootLayout({ children }) {
return (
<html>
<body>
<ThemeRegistry options={{ key: 'mui' }}>
<div>{children}</div>
</ThemeRegistry>
</body>
</html>
);
}
export const metadata = {
title: 'RootLayout',
}
"use client"
import createCache from '@emotion/cache';
import { useServerInsertedHTML } from 'next/navigation';
import { CacheProvider } from '@emotion/react';
import { ThemeProvider } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import { createTheme } from "@mui/material";
import { theme as baseTheme } from '../theme/theme';
import { useState } from "react";
const theme = createTheme({
...baseTheme,
})
// This implementation is from emotion-js
// https://github.com/emotion-js/emotion/issues/2928#issuecomment-1319747902
export default function ThemeRegistry(props) {
const { options, children } = props;
const [{ cache, flush }] = useState(() => {
const cache = createCache(options);
cache.compat = true;
const prevInsert = cache.insert;
let inserted = [];
cache.insert = (...args) => {
const serialized = args[1];
if (cache.inserted[serialized.name] === undefined) {
inserted.push(serialized.name);
}
return prevInsert(...args);
};
const flush = () => {
const prevInserted = inserted;
inserted = [];
return prevInserted;
};
return { cache, flush };
});
useServerInsertedHTML(() => {
const names = flush();
if (names.length === 0) {
return null;
}
let styles = '';
for (const name of names) {
styles += cache.inserted[name];
}
return (
<style
key={cache.key}
data-emotion={`${cache.key} ${names.join(' ')}`}
dangerouslySetInnerHTML={{
__html: styles,
}}
/>
);
});
return (
<CacheProvider value={cache}>
<ThemeProvider theme={theme}>
<CssBaseline /> // BY REMOVING THE CssBaseline COMPONENT THE PROBLEM GOES AWAY
{children}
</ThemeProvider>
</CacheProvider>
);
}
import { dehydrate } from "@tanstack/query-core";
import getQueryClient from "../utils/getQueryClient";
import Hydrate from "../utils/hydrate.client";
import ListUsers from "./list";
async function getUsers() {
const res = await fetch("https://jsonplaceholder.typicode.com/users");
const users = await res.json()
return users;
}
export default async function Hydation() {
const queryClient = getQueryClient();
await queryClient.prefetchQuery(["hydrate-users"], getUsers);
const dehydratedState = dehydrate(queryClient);
return (
<Hydrate state={dehydratedState}>
<ListUsers />
</Hydrate>
);
}
export const runtime = 'edge'; // BY REMOVING THE RUNTIME EDGE THE PROBLEM GOES AWAY The server log on a request to
It's worth noting that the error doesn't prevent the page to render My deps "@emotion/cache": "^11.10.5",
"@emotion/react": "^11.10.6",
"@emotion/server": "^11.10.0",
"@emotion/styled": "^11.10.6",
"@mui/icons-material": "^5.11.11",
"@mui/material": "^5.11.13",
"@mui/styles": "^5.8.3",
"@mui/system": "^5.11.12",
"next": "^13.4.2", |
Update: The main issue seems to be that the This causes the |
@mj12albert any chance this can be re-opened and checked out? |
@giovannidavi Thanks for the investigating this, appreciate the thorough report! I haven't gotten around to trying to reproduce it yet, but it's related to Emotion and should be fixed on their side: vercel/next.js#39229 (comment) Could you try with the latest versions of the emotion packages (should be BTW I'm not sure if this has to do with this issue – I see you are using |
PS: We've updated the |
@mj12albert thanks for the feedback and for looking at this, I've upgraded |
@giovannidavi @mj12albert I’m experiencing exactly the same issue with the same error |
@BartoszJanowski no unfortunately this is still an issue for me and it's blocking me as it breaks the SSR @mj12albert do you know if is there any plan of coming with a fix for this? |
Use for example, |
Thanks! It works for me |
@Sravan-V97 @roybasha as in the sample code I posted above Just to make sure, is your code running without the If that is the case can you please post a very basic repro steps of your code? |
@mj12albert I did some other debugging and I've found that the result of On build time the theme seems to be complete correct {
"breakpoints": {
"keys": [
"xs",
"sm",
"md",
"lg",
"xl"
],
"values": {
"xs": 0,
"sm": 600,
"md": 900,
"lg": 1200,
"xl": 1536
},
"unit": "px"
},
"direction": "ltr",
"components": {},
"palette": {
"mode": "light",
"common": {
"black": "#000",
"white": "#fff"
},
"primary": {
"main": "#1976d2",
"light": "#42a5f5",
"dark": "#1565c0",
"contrastText": "#fff"
},
"secondary": {
"main": "#9c27b0",
"light": "#ba68c8",
"dark": "#7b1fa2",
"contrastText": "#fff"
},
"error": {
"main": "#d32f2f",
"light": "#ef5350",
"dark": "#c62828",
"contrastText": "#fff"
},
"warning": {
"main": "#ed6c02",
"light": "#ff9800",
"dark": "#e65100",
"contrastText": "#fff"
},
"info": {
"main": "#0288d1",
"light": "#03a9f4",
"dark": "#01579b",
"contrastText": "#fff"
},
"success": {
"main": "#2e7d32",
"light": "#4caf50",
"dark": "#1b5e20",
"contrastText": "#fff"
},
"grey": {
"50": "#fafafa",
"100": "#f5f5f5",
"200": "#eeeeee",
"300": "#e0e0e0",
"400": "#bdbdbd",
"500": "#9e9e9e",
"600": "#757575",
"700": "#616161",
"800": "#424242",
"900": "#212121",
"A100": "#f5f5f5",
"A200": "#eeeeee",
"A400": "#bdbdbd",
"A700": "#616161"
},
"contrastThreshold": 3,
"tonalOffset": 0.2,
"text": {
"primary": "rgba(0, 0, 0, 0.87)",
"secondary": "rgba(0, 0, 0, 0.6)",
"disabled": "rgba(0, 0, 0, 0.38)"
},
"divider": "rgba(0, 0, 0, 0.12)",
"background": {
"paper": "#fff",
"default": "#fff"
},
"action": {
"active": "rgba(0, 0, 0, 0.54)",
"hover": "rgba(0, 0, 0, 0.04)",
"hoverOpacity": 0.04,
"selected": "rgba(0, 0, 0, 0.08)",
"selectedOpacity": 0.08,
"disabled": "rgba(0, 0, 0, 0.26)",
"disabledBackground": "rgba(0, 0, 0, 0.12)",
"disabledOpacity": 0.38,
"focus": "rgba(0, 0, 0, 0.12)",
"focusOpacity": 0.12,
"activatedOpacity": 0.12
}
},
"shape": {
"borderRadius": 4
},
"unstable_sxConfig": {
"border": {
"themeKey": "borders"
},
"borderTop": {
"themeKey": "borders"
},
"borderRight": {
"themeKey": "borders"
},
"borderBottom": {
"themeKey": "borders"
},
"borderLeft": {
"themeKey": "borders"
},
"borderColor": {
"themeKey": "palette"
},
"borderTopColor": {
"themeKey": "palette"
},
"borderRightColor": {
"themeKey": "palette"
},
"borderBottomColor": {
"themeKey": "palette"
},
"borderLeftColor": {
"themeKey": "palette"
},
"borderRadius": {
"themeKey": "shape.borderRadius"
},
"color": {
"themeKey": "palette"
},
"bgcolor": {
"themeKey": "palette",
"cssProperty": "backgroundColor"
},
"backgroundColor": {
"themeKey": "palette"
},
"p": {},
"pt": {},
"pr": {},
"pb": {},
"pl": {},
"px": {},
"py": {},
"padding": {},
"paddingTop": {},
"paddingRight": {},
"paddingBottom": {},
"paddingLeft": {},
"paddingX": {},
"paddingY": {},
"paddingInline": {},
"paddingInlineStart": {},
"paddingInlineEnd": {},
"paddingBlock": {},
"paddingBlockStart": {},
"paddingBlockEnd": {},
"m": {},
"mt": {},
"mr": {},
"mb": {},
"ml": {},
"mx": {},
"my": {},
"margin": {},
"marginTop": {},
"marginRight": {},
"marginBottom": {},
"marginLeft": {},
"marginX": {},
"marginY": {},
"marginInline": {},
"marginInlineStart": {},
"marginInlineEnd": {},
"marginBlock": {},
"marginBlockStart": {},
"marginBlockEnd": {},
"displayPrint": {
"cssProperty": false
},
"display": {},
"overflow": {},
"textOverflow": {},
"visibility": {},
"whiteSpace": {},
"flexBasis": {},
"flexDirection": {},
"flexWrap": {},
"justifyContent": {},
"alignItems": {},
"alignContent": {},
"order": {},
"flex": {},
"flexGrow": {},
"flexShrink": {},
"alignSelf": {},
"justifyItems": {},
"justifySelf": {},
"gap": {},
"rowGap": {},
"columnGap": {},
"gridColumn": {},
"gridRow": {},
"gridAutoFlow": {},
"gridAutoColumns": {},
"gridAutoRows": {},
"gridTemplateColumns": {},
"gridTemplateRows": {},
"gridTemplateAreas": {},
"gridArea": {},
"position": {},
"zIndex": {
"themeKey": "zIndex"
},
"top": {},
"right": {},
"bottom": {},
"left": {},
"boxShadow": {
"themeKey": "shadows"
},
"width": {},
"maxWidth": {},
"minWidth": {},
"height": {},
"maxHeight": {},
"minHeight": {},
"boxSizing": {},
"fontFamily": {
"themeKey": "typography"
},
"fontSize": {
"themeKey": "typography"
},
"fontStyle": {
"themeKey": "typography"
},
"fontWeight": {
"themeKey": "typography"
},
"letterSpacing": {},
"textTransform": {},
"lineHeight": {},
"textAlign": {},
"typography": {
"cssProperty": false,
"themeKey": "typography"
}
},
"mixins": {
"toolbar": {
"minHeight": 56,
"@media (min-width:0px)": {
"@media (orientation: landscape)": {
"minHeight": 48
}
},
"@media (min-width:600px)": {
"minHeight": 64
}
}
},
"shadows": [
"none",
"0px 2px 1px -1px rgba(0,0,0,0.2),0px 1px 1px 0px rgba(0,0,0,0.14),0px 1px 3px 0px rgba(0,0,0,0.12)",
"0px 3px 1px -2px rgba(0,0,0,0.2),0px 2px 2px 0px rgba(0,0,0,0.14),0px 1px 5px 0px rgba(0,0,0,0.12)",
"0px 3px 3px -2px rgba(0,0,0,0.2),0px 3px 4px 0px rgba(0,0,0,0.14),0px 1px 8px 0px rgba(0,0,0,0.12)",
"0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12)",
"0px 3px 5px -1px rgba(0,0,0,0.2),0px 5px 8px 0px rgba(0,0,0,0.14),0px 1px 14px 0px rgba(0,0,0,0.12)",
"0px 3px 5px -1px rgba(0,0,0,0.2),0px 6px 10px 0px rgba(0,0,0,0.14),0px 1px 18px 0px rgba(0,0,0,0.12)",
"0px 4px 5px -2px rgba(0,0,0,0.2),0px 7px 10px 1px rgba(0,0,0,0.14),0px 2px 16px 1px rgba(0,0,0,0.12)",
"0px 5px 5px -3px rgba(0,0,0,0.2),0px 8px 10px 1px rgba(0,0,0,0.14),0px 3px 14px 2px rgba(0,0,0,0.12)",
"0px 5px 6px -3px rgba(0,0,0,0.2),0px 9px 12px 1px rgba(0,0,0,0.14),0px 3px 16px 2px rgba(0,0,0,0.12)",
"0px 6px 6px -3px rgba(0,0,0,0.2),0px 10px 14px 1px rgba(0,0,0,0.14),0px 4px 18px 3px rgba(0,0,0,0.12)",
"0px 6px 7px -4px rgba(0,0,0,0.2),0px 11px 15px 1px rgba(0,0,0,0.14),0px 4px 20px 3px rgba(0,0,0,0.12)",
"0px 7px 8px -4px rgba(0,0,0,0.2),0px 12px 17px 2px rgba(0,0,0,0.14),0px 5px 22px 4px rgba(0,0,0,0.12)",
"0px 7px 8px -4px rgba(0,0,0,0.2),0px 13px 19px 2px rgba(0,0,0,0.14),0px 5px 24px 4px rgba(0,0,0,0.12)",
"0px 7px 9px -4px rgba(0,0,0,0.2),0px 14px 21px 2px rgba(0,0,0,0.14),0px 5px 26px 4px rgba(0,0,0,0.12)",
"0px 8px 9px -5px rgba(0,0,0,0.2),0px 15px 22px 2px rgba(0,0,0,0.14),0px 6px 28px 5px rgba(0,0,0,0.12)",
"0px 8px 10px -5px rgba(0,0,0,0.2),0px 16px 24px 2px rgba(0,0,0,0.14),0px 6px 30px 5px rgba(0,0,0,0.12)",
"0px 8px 11px -5px rgba(0,0,0,0.2),0px 17px 26px 2px rgba(0,0,0,0.14),0px 6px 32px 5px rgba(0,0,0,0.12)",
"0px 9px 11px -5px rgba(0,0,0,0.2),0px 18px 28px 2px rgba(0,0,0,0.14),0px 7px 34px 6px rgba(0,0,0,0.12)",
"0px 9px 12px -6px rgba(0,0,0,0.2),0px 19px 29px 2px rgba(0,0,0,0.14),0px 7px 36px 6px rgba(0,0,0,0.12)",
"0px 10px 13px -6px rgba(0,0,0,0.2),0px 20px 31px 3px rgba(0,0,0,0.14),0px 8px 38px 7px rgba(0,0,0,0.12)",
"0px 10px 13px -6px rgba(0,0,0,0.2),0px 21px 33px 3px rgba(0,0,0,0.14),0px 8px 40px 7px rgba(0,0,0,0.12)",
"0px 10px 14px -6px rgba(0,0,0,0.2),0px 22px 35px 3px rgba(0,0,0,0.14),0px 8px 42px 7px rgba(0,0,0,0.12)",
"0px 11px 14px -7px rgba(0,0,0,0.2),0px 23px 36px 3px rgba(0,0,0,0.14),0px 9px 44px 8px rgba(0,0,0,0.12)",
"0px 11px 15px -7px rgba(0,0,0,0.2),0px 24px 38px 3px rgba(0,0,0,0.14),0px 9px 46px 8px rgba(0,0,0,0.12)"
],
"typography": {
"htmlFontSize": 16,
"fontFamily": "\"Roboto\", \"Helvetica\", \"Arial\", sans-serif",
"fontSize": 14,
"fontWeightLight": 300,
"fontWeightRegular": 400,
"fontWeightMedium": 500,
"fontWeightBold": 700,
"h1": {
"fontFamily": "\"Roboto\", \"Helvetica\", \"Arial\", sans-serif",
"fontWeight": 300,
"fontSize": "6rem",
"lineHeight": 1.167,
"letterSpacing": "-0.01562em"
},
"h2": {
"fontFamily": "\"Roboto\", \"Helvetica\", \"Arial\", sans-serif",
"fontWeight": 300,
"fontSize": "3.75rem",
"lineHeight": 1.2,
"letterSpacing": "-0.00833em"
},
"h3": {
"fontFamily": "\"Roboto\", \"Helvetica\", \"Arial\", sans-serif",
"fontWeight": 400,
"fontSize": "3rem",
"lineHeight": 1.167,
"letterSpacing": "0em"
},
"h4": {
"fontFamily": "\"Roboto\", \"Helvetica\", \"Arial\", sans-serif",
"fontWeight": 400,
"fontSize": "2.125rem",
"lineHeight": 1.235,
"letterSpacing": "0.00735em"
},
"h5": {
"fontFamily": "\"Roboto\", \"Helvetica\", \"Arial\", sans-serif",
"fontWeight": 400,
"fontSize": "1.5rem",
"lineHeight": 1.334,
"letterSpacing": "0em"
},
"h6": {
"fontFamily": "\"Roboto\", \"Helvetica\", \"Arial\", sans-serif",
"fontWeight": 500,
"fontSize": "1.25rem",
"lineHeight": 1.6,
"letterSpacing": "0.0075em"
},
"subtitle1": {
"fontFamily": "\"Roboto\", \"Helvetica\", \"Arial\", sans-serif",
"fontWeight": 400,
"fontSize": "1rem",
"lineHeight": 1.75,
"letterSpacing": "0.00938em"
},
"subtitle2": {
"fontFamily": "\"Roboto\", \"Helvetica\", \"Arial\", sans-serif",
"fontWeight": 500,
"fontSize": "0.875rem",
"lineHeight": 1.57,
"letterSpacing": "0.00714em"
},
"body1": {
"fontFamily": "\"Roboto\", \"Helvetica\", \"Arial\", sans-serif",
"fontWeight": 400,
"fontSize": "1rem",
"lineHeight": 1.5,
"letterSpacing": "0.00938em"
},
"body2": {
"fontFamily": "\"Roboto\", \"Helvetica\", \"Arial\", sans-serif",
"fontWeight": 400,
"fontSize": "0.875rem",
"lineHeight": 1.43,
"letterSpacing": "0.01071em"
},
"button": {
"fontFamily": "\"Roboto\", \"Helvetica\", \"Arial\", sans-serif",
"fontWeight": 500,
"fontSize": "0.875rem",
"lineHeight": 1.75,
"letterSpacing": "0.02857em",
"textTransform": "uppercase"
},
"caption": {
"fontFamily": "\"Roboto\", \"Helvetica\", \"Arial\", sans-serif",
"fontWeight": 400,
"fontSize": "0.75rem",
"lineHeight": 1.66,
"letterSpacing": "0.03333em"
},
"overline": {
"fontFamily": "\"Roboto\", \"Helvetica\", \"Arial\", sans-serif",
"fontWeight": 400,
"fontSize": "0.75rem",
"lineHeight": 2.66,
"letterSpacing": "0.08333em",
"textTransform": "uppercase"
},
"inherit": {
"fontFamily": "inherit",
"fontWeight": "inherit",
"fontSize": "inherit",
"lineHeight": "inherit",
"letterSpacing": "inherit"
}
},
"transitions": {
"easing": {
"easeInOut": "cubic-bezier(0.4, 0, 0.2, 1)",
"easeOut": "cubic-bezier(0.0, 0, 0.2, 1)",
"easeIn": "cubic-bezier(0.4, 0, 1, 1)",
"sharp": "cubic-bezier(0.4, 0, 0.6, 1)"
},
"duration": {
"shortest": 150,
"shorter": 200,
"short": 250,
"standard": 300,
"complex": 375,
"enteringScreen": 225,
"leavingScreen": 195
}
},
"zIndex": {
"mobileStepper": 1000,
"fab": 1050,
"speedDial": 1050,
"appBar": 1100,
"drawer": 1200,
"modal": 1300,
"snackbar": 1400,
"tooltip": 1500
}
}
but on {
"breakpoints": {
"keys": [
"xs",
"sm",
"md",
"lg",
"xl"
],
"values": {
"xs": 0,
"sm": 600,
"md": 900,
"lg": 1200,
"xl": 1536
},
"unit": "px"
},
"direction": "ltr",
"components": {},
"palette": {
"mode": "light"
},
"shape": {
"borderRadius": 4
},
"unstable_sxConfig": {
"border": {
"themeKey": "borders"
},
"borderTop": {
"themeKey": "borders"
},
"borderRight": {
"themeKey": "borders"
},
"borderBottom": {
"themeKey": "borders"
},
"borderLeft": {
"themeKey": "borders"
},
"borderColor": {
"themeKey": "palette"
},
"borderTopColor": {
"themeKey": "palette"
},
"borderRightColor": {
"themeKey": "palette"
},
"borderBottomColor": {
"themeKey": "palette"
},
"borderLeftColor": {
"themeKey": "palette"
},
"borderRadius": {
"themeKey": "shape.borderRadius"
},
"color": {
"themeKey": "palette"
},
"bgcolor": {
"themeKey": "palette",
"cssProperty": "backgroundColor"
},
"backgroundColor": {
"themeKey": "palette"
},
"p": {},
"pt": {},
"pr": {},
"pb": {},
"pl": {},
"px": {},
"py": {},
"padding": {},
"paddingTop": {},
"paddingRight": {},
"paddingBottom": {},
"paddingLeft": {},
"paddingX": {},
"paddingY": {},
"paddingInline": {},
"paddingInlineStart": {},
"paddingInlineEnd": {},
"paddingBlock": {},
"paddingBlockStart": {},
"paddingBlockEnd": {},
"m": {},
"mt": {},
"mr": {},
"mb": {},
"ml": {},
"mx": {},
"my": {},
"margin": {},
"marginTop": {},
"marginRight": {},
"marginBottom": {},
"marginLeft": {},
"marginX": {},
"marginY": {},
"marginInline": {},
"marginInlineStart": {},
"marginInlineEnd": {},
"marginBlock": {},
"marginBlockStart": {},
"marginBlockEnd": {},
"displayPrint": {
"cssProperty": false
},
"display": {},
"overflow": {},
"textOverflow": {},
"visibility": {},
"whiteSpace": {},
"flexBasis": {},
"flexDirection": {},
"flexWrap": {},
"justifyContent": {},
"alignItems": {},
"alignContent": {},
"order": {},
"flex": {},
"flexGrow": {},
"flexShrink": {},
"alignSelf": {},
"justifyItems": {},
"justifySelf": {},
"gap": {},
"rowGap": {},
"columnGap": {},
"gridColumn": {},
"gridRow": {},
"gridAutoFlow": {},
"gridAutoColumns": {},
"gridAutoRows": {},
"gridTemplateColumns": {},
"gridTemplateRows": {},
"gridTemplateAreas": {},
"gridArea": {},
"position": {},
"zIndex": {
"themeKey": "zIndex"
},
"top": {},
"right": {},
"bottom": {},
"left": {},
"boxShadow": {
"themeKey": "shadows"
},
"width": {},
"maxWidth": {},
"minWidth": {},
"height": {},
"maxHeight": {},
"minHeight": {},
"boxSizing": {},
"fontFamily": {
"themeKey": "typography"
},
"fontSize": {
"themeKey": "typography"
},
"fontStyle": {
"themeKey": "typography"
},
"fontWeight": {
"themeKey": "typography"
},
"letterSpacing": {},
"textTransform": {},
"lineHeight": {},
"textAlign": {},
"typography": {
"cssProperty": false,
"themeKey": "typography"
}
}
} hope this shed some more light |
Hi everyone - We are also experiencing issues with |
same issue here |
hey mate, any luck on this issue? |
@ManuRodgers no updates on this so far, unfortunately.. we had to opt out cloudflare and edge runtime for the time being. |
Same here, really annoying. Latest MUI, the theme can be as trivial as: export const myTheme = createTheme({
palette: {
mode: "light",
text: {
primary: "#5e586c",
secondary: "#6f6b7d",
disabled: "#00000061",
},
},
}); No error during recompilation, but upon opening the page in browser I'm seeing:
Goes away as soon as I comment out: export const runtime = "edge"; Versions:
|
Any update regarding this issue? Seem next release better support for emotion css cache but the issue still there. This will break in CI/CD. |
Sadly, I'm with the same problem :( |
Any updates on this? 🙏 |
Duplicate of #39338. |
Fixed by #39981 |
Steps to reproduce 🕹
Link to live example:
Steps:
Current behavior 😯
No response
Expected behavior 🤔
No response
Context 🔦
No response
Your environment 🌎
npx @mui/envinfo
The text was updated successfully, but these errors were encountered: