Reputation: 145
I'm experiencing an issue when building my Next.js project in GitHub Actions. The build process gets stuck for several minutes while trying to fetch Google Fonts, and sometimes it fails completely. Here is the relevant error log:
#12 10.13 Creating an optimized production build ...
#12 52.98 request to https://fonts.gstatic.com/s/ubuntu/v20/4iCv6KVjbNBYlgoC1CzjvWyNPYZvg7UI.woff2 failed, reason:
#12 52.98
#12 52.98 Retrying 1/3...
#12 52.99 request to https://fonts.gstatic.com/s/ubuntu/v20/4iCv6KVjbNBYlgoC1CzjtGyNPYZvg7UI.woff2 failed, reason:
#12 52.99
#12 52.99 Retrying 1/3...
#12 52.99 request to https://fonts.gstatic.com/s/ubuntu/v20/4iCv6KVjbNBYlgoC1CzjvGyNPYZvg7UI.woff2 failed, reason:
#12 52.99
#12 52.99 Retrying 1/3...
#12 53.00 request to https://fonts.gstatic.com/s/ubuntu/v20/4iCv6KVjbNBYlgoC1Czjs2yNPYZvg7UI.woff2 failed, reason:
#12 53.00
#12 53.00 Retrying 1/3...
#12 53.01 request to https://fonts.gstatic.com/s/ubuntu/v20/4iCv6KVjbNBYlgoC1CzjvmyNPYZvg7UI.woff2 failed, reason:
#12 53.01
#12 53.01 Retrying 1/3...
#12 53.01 request to https://fonts.gstatic.com/s/ubuntu/v20/4iCv6KVjbNBYlgoC1CzjsGyNPYZvgw.woff2 failed, reason:
#12 53.01
#12 53.01 Retrying 1/3...
#12 53.02 request to https://fonts.gstatic.com/s/ubuntu/v20/4iCs6KVjbNBYlgoKew72nU6AF7xm.woff2 failed, reason:
.
.
.
It retries multiple times, and in some cases, it succeeds after ~7 minutes. However, occasionally, the build fails entirely because it cannot fetch the fonts.
This is how I import the fonts in my Next.js project:
import "../styles/globals.css";
import "../styles/Main.scss";
import Head from "./head";
import NextAuthSessionProvider from "./SessionProvider";
import { Oswald, Ubuntu, Play } from 'next/font/google';
const oswald = Oswald({ subsets: ['latin'] });
const ubuntu = Ubuntu({ weight: ['300', '400', '500', '700'], subsets: ['latin'] });
const play = Play({ weight: ['400', '700'], subsets: ['latin'] });
export default function RootLayout({ children }) {
return (
<html lang="en" className={`${oswald.className} ${ubuntu.className} ${play.className}`}>
<Head />
<body>
<NextAuthSessionProvider>
{children}
</NextAuthSessionProvider>
</body>
</html>
);
}
Running the build locally works fine. Any ideas on how to shorten the build time and fix this error?
Upvotes: 0
Views: 31