next-runtime
next-runtime copied to clipboard
[Bug]: Build of a nextjs app fails in netlify and clean cache and retry deploy is needed
Summary
Hi, our nextjs application is hosted in netlify, from time to time our build fails with not reason, and we need to click on clear cache and retry deploy again, most of the time we got this error.
I am not sure if this is something related with the plugin or with our code, but the strange part is that we never get the error running it in our local environments.
Could you please give us some hints, because it is getting a bit cumbersome due to the increasing number of sites we are deploying.
our plugin version is "@netlify/plugin-nextjs": "4.7.1",
Steps to reproduce
There is no way to reproduce, it happens from time to time.
A link to a reproduction repository
No response
Plugin version
4.7.1
More information about your build
- [ ] I am building using the CLI
- [X] I am building using file-based configuration (
netlify.toml
)
What OS are you using?
Mac OS
Your netlify.toml file
`netlify.toml`
[[redirects]]
from = "/locale.json"
to = "/locales/at.json"
force = true
status = 200
conditions = {Country = ["AT"]}
[[redirects]]
from = "/locale.json"
to = "/locales/de.json"
force = true
status = 200
conditions = {Country = ["DE"]}
[[redirects]]
from = "/locale.json"
to = "/locales/fr.json"
force = true
status = 200
conditions = {Country = ["BE"], Language = ["fr", "fr-BE"]}
[[redirects]]
from = "/locale.json"
to = "/locales/be.json"
force = true
status = 200
conditions = {Country = ["BE"]}
[[redirects]]
from = "/locale.json"
to = "/locales/nl.json"
force = true
status = 200
conditions = {Country = ["NL"]}
[[redirects]]
from = "/locale.json"
to = "/locales/fr.json"
force = true
status = 200
conditions = {Country = ["FR"]}
[[redirects]]
from = "/locale.json"
to = "/locales/ch.json"
force = true
status = 200
conditions = {Country = ["CH"]}
[[redirects]]
from = "/locale.json"
to = "/locales/uk.json"
force = true
status = 200
conditions = {Country = ["UK", "GB"]}
[[redirects]]
from = "/locale.json"
to = "/locales/it.json"
force = true
status = 200
conditions = {Country = ["IT"]}
[[redirects]]
from = "/locale.json"
to = "/locales/se.json"
force = true
status = 200
conditions = {Country = ["SE"]}
# Add Strict-Transport-Security header, see https://docs.netlify.com/domains-https/https-ssl/#hsts-preload
[[headers]]
for = "/*"
[headers.values]
Strict-Transport-Security = '''
max-age=63072000;
includeSubDomains;
preload'''
# Deploy Preview context:
# All deploys generated from a pull/merge request will inherit these settings.
# This is out staging environment that is connected to the staging space in builder.io
[build]
command = "yarn ci:build:webshop"
publish = "packages/webshop/.next"
[build.environment]
TERM = "xterm"
CYPRESS_CACHE_FOLDER = "./node_modules/CypressBinary"
NETLIFY_USE_YARN = "true"
YARN_VERSION = "3.1.1"
CI = "1"
[[plugins]]
package = "@netlify/plugin-nextjs"
[[plugins]]
package = "/plugins/netlify-lighthouse"
[context.deploy-preview.environment]
SHOPIFY_ADMIN_API_TOKEN=xxxxxx
SHOPIFY_STOREFRONT_API_TOKEN=xxxxx
SHOPIFY_STORE_DOMAIN=xxxxx
SHOPIFY_GRAPHQL_ADMIN_API_ENDPOINT=xxxx
SHOPIFY_GRAPHQL_ENDPOINT=xxxx
BUILDER_PUBLIC_KEY=xxxx
BUILDER_GRAPHQL_ENDPOINT=xxxx
LOCALES=xxx
LOCALE_DEFAULT=xxxx
SHIPPING_COUNTRIES=xxxx
SENTRY_AUTH_TOKEN=xxxx
DEFAULT_CURRENCY=xxx
E2E_TEST_EMAIL=xxxx
E2E_TEST_PASSWORD=xxxx
Your public/_redirects file
`_redirects`
# Paste content of your `_redirects` file here
Your next.config.js
file
`next.config.js`
// eslint-disable-next-line @typescript-eslint/no-var-requires
// const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const { withSentryConfig } = require('@sentry/nextjs');
const withPlugins = require('next-compose-plugins');
const withTM = require('next-transpile-modules')(['@airup/ui', '@airup/services']);
const withPWA = require('next-pwa');
const runtimeCaching = require('next-pwa/cache');
const fs = require('fs');
const withImageLoader = require('next-image-loader');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const bundleAnalyzer = require('@next/bundle-analyzer')({
enabled: !!process.env.BUNDLE_ANALYZE,
});
// Verify that the corresponding env variables for the locales are set.
if (!process.env.LOCALES) {
throw new Error('Missing env variable LOCALES');
}
if (!process.env.LOCALE_DEFAULT) {
throw new Error('Missing env variable LOCALE_DEFAULT');
}
//Verify that the corresponding env variables for the locales are set.
if (!process.env.SHIPPING_COUNTRIES) {
throw new Error('Missing env variable SHIPPING_COUNTRIES');
}
if (!process.env.SENTRY_AUTH_TOKEN) {
throw new Error('Missing env variable SENTRY_AUTH_TOKEN');
}
if (!process.env.COUNTRY_CODE) {
throw new Error('Missing env variable COUNTRY_CODE');
}
const LOCALES = process.env.LOCALES.split(',');
const SHIPPING_COUNTRIES = process.env.SHIPPING_COUNTRIES?.split(',') ?? [process.env.COUNTRY_CODE ?? 'de'];
console.log('🛍 Store: ', process.env.COUNTRY_CODE);
console.log('🗺 Locales: ', LOCALES);
console.log('🚚 Shipping Countries: ', SHIPPING_COUNTRIES);
const moduleExports = {
eslint: {
ignoreDuringBuilds: true,
},
webpack: (config) => {
config.module.rules.push({
test: /\.tsx?$/,
use: {
loader: 'ts-loader',
options: {
transpileOnly: true,
projectReferences: true,
},
},
});
// config.plugins.push(new ForkTsCheckerWebpackPlugin());
return config;
},
images: {
domains: [
'cdn.shopify.com',
'cdn.builder.io',
'via.placeholder.com',
'source.unsplash.com',
'resources.bamboohr.com',
'picsum.photos',
],
formats: ['image/avif', 'image/webp'],
deviceSizes: [120, 240, 480, 720, 960, 1200, 1440],
},
async redirects() {
// Fetching redirects from Builder.io
try {
const response = await fetch(process.env.BUILDER_GRAPHQL_ENDPOINT, {
method: 'POST',
headers: {
'content-type': 'application/json',
},
body: JSON.stringify({
query: `
query BuilderRedirects {
oneDataRedirects {
data {
redirects
}
}
}`,
operationName: 'BuilderRedirects',
}),
});
const parsedJsonObject = await response.json();
const redirectsBuilder = (parsedJsonObject.data.oneDataRedirects?.data.redirects || [])
/*
Pick only valid keys, inject `permanent` where necessary
Parse the source and extract query params if there are any
*/
.map(({ source, destination, permanent = false }) => {
try {
const url = new URL(`${process.env.SITE_URL}${source}`);
const has = [...url.searchParams.entries()].map(([key, value]) => ({
type: 'query',
key,
value,
}));
return {
source: url.pathname,
destination,
permanent,
// only add the key if it has any content at all
...(has.length ? { has } : undefined),
};
} catch (e) {
console.log(` ❌ Invalid redirect source: ${source}`);
return {};
}
})
// Sanitize entries
.filter(({ source, destination }) => Boolean(source && destination));
console.log(`🌐🔗 Builder Redirects (${redirectsBuilder.length}):`, `✅`);
return redirectsBuilder;
} catch (error) {
console.log('🌐🔗 Builder Redirects: ❌');
console.log(error);
return [];
}
},
async headers() {
return [
{
source: '/:path*',
headers: [
{
key: 'Content-Security-Policy',
value: 'frame-ancestors https://*.builder.io https://builder.io http://localhost:1234',
},
{
key: 'Strict-Transport-Security',
value: 'max-age=63072000; includeSubDomains; preload',
},
],
},
];
},
env: {
// expose env to the browser
SHOPIFY_ADMIN_API_TOKEN: process.env.SHOPIFY_ADMIN_API_TOKEN,
SHOPIFY_GRAPHQL_ADMIN_API_ENDPOINT: process.env.SHOPIFY_GRAPHQL_ADMIN_API_ENDPOINT,
SHOPIFY_STOREFRONT_API_TOKEN: process.env.SHOPIFY_STOREFRONT_API_TOKEN,
SHOPIFY_STORE_DOMAIN: process.env.SHOPIFY_STORE_DOMAIN,
SHOPIFY_GRAPHQL_ENDPOINT: process.env.SHOPIFY_GRAPHQL_ENDPOINT,
BUILDER_PUBLIC_KEY: process.env.BUILDER_PUBLIC_KEY,
BUILDER_GRAPHQL_ENDPOINT: process.env.BUILDER_GRAPHQL_ENDPOINT,
IS_DEMO: process.env.IS_DEMO,
LOCALES: process.env.LOCALES,
LOCALE_DEFAULT: process.env.LOCALE_DEFAULT,
SHIPPING_COUNTRIES: process.env.SHIPPING_COUNTRIES,
COUNTRY_CODE: process.env.COUNTRY_CODE,
DEFAULT_CURRENCY: process.env.DEFAULT_CURRENCY,
SENTRY_AUTH_TOKEN: process.env.SENTRY_AUTH_TOKEN,
SITE_URL: process.env.SITE_URL,
GTM_CONTAINER_ID: process.env.GTM_CONTAINER_ID,
GTM_AUTH: process.env.GTM_AUTH,
GTM_PREVIEW_ID: process.env.GTM_PREVIEW_ID,
USERCENTRICS_ID: process.env.USERCENTRICS_ID,
SHOPIFY_MULTIPASS_SECRET: process.env.SHOPIFY_MULTIPASS_SECRET,
ENABLE_PASS_PROTECTION: process.env.ENABLE_PASS_PROTECTION,
KUSTOMER_API_KEY: process.env.KUSTOMER_API_KEY,
KUSTOMER_BRAND_ID: process.env.KUSTOMER_BRAND_ID,
HIDE_VAT: process.env.HIDE_VAT,
},
i18n: {
// These are all the locales you want to support in your application
locales: LOCALES,
// This is the default locale you want to be used when visiting a non-locale prefixed path e.g. `/hello`
defaultLocale: process.env.LOCALE_DEFAULT,
},
pwa: {
dest: 'public',
runtimeCaching,
},
};
const SentryWebpackPluginOptions = {
silent: true, // Suppresses all logs
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
};
// @Todo: remove withImageLoader as soon as netlify fixes the 502 issue on their nextjs plugin - they told us they will hold us updated on this topic
// Do not log with sentry in development environments
if (process.env.NODE_ENV !== 'development') {
module.exports = withPlugins([bundleAnalyzer, withSentryConfig, withTM, withPWA, withImageLoader], moduleExports);
} else {
module.exports = withPlugins([bundleAnalyzer, withTM, withPWA, withImageLoader], moduleExports);
}
Builds logs (or link to your logs)
Build logs
https://app.netlify.com/sites/airup-webshop-dev1/deploys/62a812153badfa00092d6736
Function logs
Function logs
https://app.netlify.com/sites/airup-webshop-dev1/functions/___netlify-handler
https://app.netlify.com/sites/airup-webshop-dev1/functions/___netlify-odb-handler
https://app.netlify.com/sites/airup-webshop-dev1/functions/_ipx
.next JSON files
generated .next JSON files
build-manifest.json
{
"polyfillFiles": [
"static/chunks/polyfills.js"
],
"devFiles": [
"static/chunks/react-refresh.js"
],
"ampDevFiles": [
"static/chunks/webpack.js",
"static/chunks/amp.js"
],
"lowPriorityFiles": [
"static/development/_buildManifest.js",
"static/development/_ssgManifest.js",
"static/development/_middlewareManifest.js"
],
"pages": {
"/[[...path]]": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/[[...path]].js"
],
"/_app": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/_app.js"
],
"/_error": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/_error.js"
],
"/account": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/account.js"
],
"/account/_middleware": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"server/pages/account/_middleware.js"
],
"/account/login": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/account/login.js"
]
},
"ampFirstPages": []
}
react-loadable-manifest.json
{
"../../ui/components/Video/Video.tsx -> react-player": {
"id": "../../node_modules/react-player/lib/index.js",
"files": [
"static/chunks/node_modules_react-player_lib_index_js.js"
]
},
"../../ui/components/builder.ts -> ./Accordion/Accordion.builder": {
"id": "../ui/components/Accordion/Accordion.builder.tsx",
"files": [
"static/chunks/ui_components_Accordion_Accordion_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./AnnouncementBar/AnnouncementBar.builder": {
"id": "../ui/components/AnnouncementBar/AnnouncementBar.builder.tsx",
"files": [
"static/chunks/ui_components_AnnouncementBar_AnnouncementBar_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./BambooHR/BambooHR.builder": {
"id": "../ui/components/BambooHR/BambooHR.builder.tsx",
"files": [
"static/chunks/ui_components_BambooHR_BambooHR_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./Breadcrumb/Breadcrumb.builder": {
"id": "../ui/components/Breadcrumb/Breadcrumb.builder.tsx",
"files": [
"static/chunks/ui_components_Breadcrumb_Breadcrumb_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./Button/Button.builder": {
"id": "../ui/components/Button/Button.builder.tsx",
"files": [
"static/chunks/ui_components_Button_Button_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./Carousel/Carousel.builder": {
"id": "../ui/components/Carousel/Carousel.builder.tsx",
"files": [
"static/chunks/ui_components_Carousel_Carousel_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./Columns/Columns.builder": {
"id": "../ui/components/Columns/Columns.builder.tsx",
"files": [
"static/chunks/ui_components_Columns_Columns_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./CompositionBottomBar/CompositionBottomBar.builder": {
"id": "../ui/components/CompositionBottomBar/CompositionBottomBar.builder.tsx",
"files": [
"static/chunks/ui_components_CompositionBottomBar_CompositionBottomBar_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./CompositionFooter/CompositionFooter.builder": {
"id": "../ui/components/CompositionFooter/CompositionFooter.builder.tsx",
"files": [
"static/chunks/ui_components_CompositionFooter_CompositionFooter_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./CompositionHeader/CompositionHeader.builder": {
"id": "../ui/components/CompositionHeader/CompositionHeader.builder.tsx",
"files": [
"static/chunks/ui_components_CompositionHeader_CompositionHeader_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./CompositionPageTitle/CompositionPageTitle.builder": {
"id": "../ui/components/CompositionPageTitle/CompositionPageTitle.builder.tsx",
"files": [
"static/chunks/ui_components_CompositionPageTitle_CompositionPageTitle_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./CompositionProductLogistics/CompositionProductLogistics.builder": {
"id": "../ui/components/CompositionProductLogistics/CompositionProductLogistics.builder.tsx",
"files": [
"static/chunks/ui_components_CompositionProductLogistics_CompositionProductLogistics_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./GeolocationBanner/GeolocationBanner.builder": {
"id": "../ui/components/GeolocationBanner/GeolocationBanner.builder.tsx",
"files": [
"static/chunks/ui_components_GeolocationBanner_GeolocationBanner_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./Grid/Grid.builder": {
"id": "../ui/components/Grid/Grid.builder.tsx",
"files": [
"static/chunks/ui_components_Grid_Grid_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./Headline/Headline.builder": {
"id": "../ui/components/Headline/Headline.builder.tsx",
"files": []
},
"../../ui/components/builder.ts -> ./Hero/Hero.builder": {
"id": "../ui/components/Hero/Hero.builder.tsx",
"files": [
"static/chunks/ui_components_Hero_Hero_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./Hero2/Hero2.builder": {
"id": "../ui/components/Hero2/Hero2.builder.tsx",
"files": [
"static/chunks/ui_components_Hero2_Hero2_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./HeroVideo/HeroVideo.builder": {
"id": "../ui/components/HeroVideo/HeroVideo.builder.tsx",
"files": [
"static/chunks/ui_components_HeroVideo_HeroVideo_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./Icon/Icon.builder": {
"id": "../ui/components/Icon/Icon.builder.tsx",
"files": [
"static/chunks/ui_components_Icon_Icon_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./IconLabel/IconLabel.builder": {
"id": "../ui/components/IconLabel/IconLabel.builder.tsx",
"files": [
"static/chunks/ui_components_IconLabel_IconLabel_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./Image/Image.builder": {
"id": "../ui/components/Image/Image.builder.tsx",
"files": [
"static/chunks/ui_components_Image_Image_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./KlaviyoForm/KlaviyoForm": {
"id": "../ui/components/KlaviyoForm/KlaviyoForm.tsx",
"files": [
"static/chunks/ui_components_KlaviyoForm_KlaviyoForm_tsx.js"
]
},
"../../ui/components/builder.ts -> ./LanguageSwitcher/LanguageSwitcher.builder": {
"id": "../ui/components/LanguageSwitcher/LanguageSwitcher.builder.tsx",
"files": [
"static/chunks/ui_components_LanguageSwitcher_LanguageSwitcher_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./Link/Link.builder": {
"id": "../ui/components/Link/Link.builder.tsx",
"files": [
"static/chunks/ui_components_Link_Link_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./NutritionTable/NutritionTable.builder": {
"id": "../ui/components/NutritionTable/NutritionTable.builder.tsx",
"files": [
"static/chunks/ui_components_NutritionTable_NutritionTable_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./Paragraph/Paragraph.builder": {
"id": "../ui/components/Paragraph/Paragraph.builder.tsx",
"files": [
"static/chunks/ui_components_Paragraph_Paragraph_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./ParcelPerform/ParcelPerform.builder": {
"id": "../ui/components/ParcelPerform/ParcelPerform.builder.tsx",
"files": [
"static/chunks/ui_components_ParcelPerform_ParcelPerform_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./ResponsiveVisibility/ResponsiveVisibility.builder": {
"id": "../ui/components/ResponsiveVisibility/ResponsiveVisibility.builder.tsx",
"files": [
"static/chunks/ui_components_ResponsiveVisibility_ResponsiveVisibility_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./Section/Section.builder": {
"id": "../ui/components/Section/Section.builder.tsx",
"files": [
"static/chunks/ui_components_Section_Section_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./Spacer/Spacer.builder": {
"id": "../ui/components/Spacer/Spacer.builder.tsx",
"files": [
"static/chunks/ui_components_Spacer_Spacer_builder_tsx.js"
]
},
"../../ui/components/builder.ts -> ./Video/Video.builder": {
"id": "../ui/components/Video/Video.builder.tsx",
"files": [
"static/chunks/ui_components_Video_Video_builder_tsx.js"
]
},
"../components/ProductCard/ProductCard.tsx -> ../Cart/CartAdd": {
"id": "./components/Cart/CartAdd.tsx",
"files": [
"static/chunks/components_Cart_CartAdd_tsx.js"
]
},
"../components/ProductCard/ProductCard.tsx -> @airup/ui/components/ReviewStars": {
"id": "../ui/components/ReviewStars/index.tsx",
"files": [
"static/chunks/ui_components_ReviewStars_index_tsx.js"
]
},
"../components/ProductCard/ProductCardSmall.tsx -> @airup/ui/components/ReviewStars": {
"id": "../ui/components/ReviewStars/index.tsx",
"files": [
"static/chunks/ui_components_ReviewStars_index_tsx.js"
]
},
"../components/VirtualStarterSet/VirtualStarterSet.tsx -> ./VirtualStarterSetVisual": {
"id": "./components/VirtualStarterSet/VirtualStarterSetVisual/index.ts",
"files": [
"static/chunks/components_VirtualStarterSet_VirtualStarterSetVisual_index_ts.js"
]
},
"../components/builder.ts -> ./CartButton/CartButton.builder": {
"id": "./components/CartButton/CartButton.builder.tsx",
"files": [
"static/chunks/components_CartButton_CartButton_builder_tsx.js"
]
},
"../components/builder.ts -> ./PaymentList/PaymentList.builder": {
"id": "./components/PaymentList/PaymentList.builder.tsx",
"files": [
"static/chunks/components_PaymentList_PaymentList_builder_tsx.js"
]
},
"../components/builder.ts -> ./ProductCard/ProductCard.builder": {
"id": "./components/ProductCard/ProductCard.builder.tsx",
"files": [
"static/chunks/components_ProductCard_ProductCard_builder_tsx.js"
]
},
"../components/builder.ts -> ./ProductCollection/ProductCollection.builder": {
"id": "./components/ProductCollection/ProductCollection.builder.tsx",
"files": [
"static/chunks/components_ProductCollection_ProductCollection_builder_tsx.js"
]
},
"../components/builder.ts -> ./Testimonial/Testimonial.builder": {
"id": "./components/Testimonial/Testimonial.builder.tsx",
"files": [
"static/chunks/components_Testimonial_Testimonial_builder_tsx.js"
]
},
"../components/builder.ts -> ./VirtualStarterSet/VirtualStarterSet.builder": {
"id": "./components/VirtualStarterSet/VirtualStarterSet.builder.tsx",
"files": [
"static/chunks/components_VirtualStarterSet_VirtualStarterSet_builder_tsx.js"
]
}
}
Example of this error can be seen here: https://app.netlify.com/sites/airup-webshop-dev1/deploys/62a812153badfa00092d6736
Closing as stale