Hello,
i've a problem after deploying my app with serverless-next.[email protected] :
i can't fetch some chunks : when i open the network tab, i see some JS and CSS chunks with a 403 error code in "_next/static" folder
i have to manually upload generated files by "npx command" in the "_next/static" S3 bucket :'(
My serverless.yml file :
# serverless.yml
myNextApplication:
component: serverless-next.js
And my next.config.js :
// next.config.js
const withSass = require("@zeit/next-sass");
// const withOffline = require('next-offline')
require('dotenv').config()
const path = require('path')
const Dotenv = require('dotenv-webpack')
// withOffline
module.exports = withSass({
target: "serverless",
// transformManifest: manifest => ['/'].concat(manifest), // add the homepage to the cache
// // Trying to set NODE_ENV=production when running yarn dev causes a build-time error so we
// // turn on the SW in dev mode so that we can actually test it
// // generateInDevMode: true,
// scope: "/",
// workboxOpts: {
// swDest: 'public/service-worker.js'
// },
webpack: (config, options) => {
config.module.rules.push({
test: /\.svg$/,
use: ["@svgr/webpack", "file-loader"]
});
config.plugins = config.plugins || [];
config.plugins = [
...config.plugins,
// Read the .env file
new Dotenv({
path: path.join(__dirname, '.env'),
systemvars: true
})
]
return config;
}
});
And i see these errors :
Uncaught (in promise) ChunkLoadError: Loading chunk 19 failed.
@antoinemaz Could you please list which chunks are failing? Also post your .next/build-manifest.json please.
Ok, so the following chunks are failing :
_next/static/chunks/50.bcd87c268373c6034627.js
_next/static/chunks/53.2a355333bf20aeda10f3.js
_next/static/chunks/51.6b524a5a47b5192d754c.js
_next/static/chunks/49.5cd186ae2b1c74f47076.js
_next/static/chunks/30cd56ec8b4292fd1d19f6bfd4b67b1689d06305.abc9c7d818c21f563b2b.js
_next/static/chunks/56.79598ae743423ad549b1.js
_next/static/chunks/48.8e0ac5571cc8144f8eb0.js
Here is my build-manifest.json :
{
"devFiles": [],
"lowPriorityFiles": [
"static/1iP06IketN-auDUNXkxae/_buildManifest.js",
"static/1iP06IketN-auDUNXkxae/_ssgManifest.js"
],
"pages": {
"/": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/359540dcbb6e24a567b648fffa3ff60e0db92c56.2d667fcfad0ef88b061c.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/404": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/359540dcbb6e24a567b648fffa3ff60e0db92c56.2d667fcfad0ef88b061c.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/_app": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/_error": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/_polyfills": [
"static/runtime/polyfills-a7a3971fc18cb3c95666.js"
],
"/about": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/359540dcbb6e24a567b648fffa3ff60e0db92c56.2d667fcfad0ef88b061c.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/account/forgotPassword": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/6e6ee531936b93d5d63d7dc3452f34a2fe45ccb4.2306852bb0332ed2c5fc.js",
"static/chunks/503785d95e8583fc48e68d3878fec486d9744f25.4948bd72653b7ed391c0.js",
"static/chunks/0254035b683c620221bc8645b19b4b78d59e7e24.e9ba235ed20e568c372e.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/account/forgotPasswordValidated": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/503785d95e8583fc48e68d3878fec486d9744f25.4948bd72653b7ed391c0.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/account/invitation": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/6e6ee531936b93d5d63d7dc3452f34a2fe45ccb4.2306852bb0332ed2c5fc.js",
"static/chunks/503785d95e8583fc48e68d3878fec486d9744f25.4948bd72653b7ed391c0.js",
"static/chunks/0254035b683c620221bc8645b19b4b78d59e7e24.e9ba235ed20e568c372e.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/account/login": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/6e6ee531936b93d5d63d7dc3452f34a2fe45ccb4.2306852bb0332ed2c5fc.js",
"static/chunks/503785d95e8583fc48e68d3878fec486d9744f25.4948bd72653b7ed391c0.js",
"static/chunks/0254035b683c620221bc8645b19b4b78d59e7e24.e9ba235ed20e568c372e.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/account/register": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/6e6ee531936b93d5d63d7dc3452f34a2fe45ccb4.2306852bb0332ed2c5fc.js",
"static/chunks/503785d95e8583fc48e68d3878fec486d9744f25.4948bd72653b7ed391c0.js",
"static/chunks/0254035b683c620221bc8645b19b4b78d59e7e24.e9ba235ed20e568c372e.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/account/registerExpired": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/503785d95e8583fc48e68d3878fec486d9744f25.4948bd72653b7ed391c0.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/account/registerValidated": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/503785d95e8583fc48e68d3878fec486d9744f25.4948bd72653b7ed391c0.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/account/resetPassword": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/6e6ee531936b93d5d63d7dc3452f34a2fe45ccb4.2306852bb0332ed2c5fc.js",
"static/chunks/503785d95e8583fc48e68d3878fec486d9744f25.4948bd72653b7ed391c0.js",
"static/chunks/0254035b683c620221bc8645b19b4b78d59e7e24.e9ba235ed20e568c372e.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/account/resetPasswordValidated": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/503785d95e8583fc48e68d3878fec486d9744f25.4948bd72653b7ed391c0.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/categorie/[name]": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/359540dcbb6e24a567b648fffa3ff60e0db92c56.2d667fcfad0ef88b061c.js",
"static/chunks/50e1587f9bd2e7a7952c74b7947f93ebd068ffc4.9b95a01c9e45e95de284.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/categories": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/359540dcbb6e24a567b648fffa3ff60e0db92c56.2d667fcfad0ef88b061c.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/exclusivite": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/359540dcbb6e24a567b648fffa3ff60e0db92c56.2d667fcfad0ef88b061c.js",
"static/chunks/50e1587f9bd2e7a7952c74b7947f93ebd068ffc4.9b95a01c9e45e95de284.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/index": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/359540dcbb6e24a567b648fffa3ff60e0db92c56.2d667fcfad0ef88b061c.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/legal": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/359540dcbb6e24a567b648fffa3ff60e0db92c56.2d667fcfad0ef88b061c.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/news": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/359540dcbb6e24a567b648fffa3ff60e0db92c56.2d667fcfad0ef88b061c.js",
"static/chunks/50e1587f9bd2e7a7952c74b7947f93ebd068ffc4.9b95a01c9e45e95de284.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/podcasts/[type]/[id]/[name]": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/75fc9c18.19556d0bdea1d34cc86c.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/359540dcbb6e24a567b648fffa3ff60e0db92c56.2d667fcfad0ef88b061c.js",
"static/chunks/ef650c354c32d40407880a1b7d370a58f1a12ea2.00a65c7104961bdb8e6a.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/privacy": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/359540dcbb6e24a567b648fffa3ff60e0db92c56.2d667fcfad0ef88b061c.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/results": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/75fc9c18.19556d0bdea1d34cc86c.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/359540dcbb6e24a567b648fffa3ff60e0db92c56.2d667fcfad0ef88b061c.js",
"static/chunks/ef650c354c32d40407880a1b7d370a58f1a12ea2.00a65c7104961bdb8e6a.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/studio/administration": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/6e6ee531936b93d5d63d7dc3452f34a2fe45ccb4.2306852bb0332ed2c5fc.js",
"static/chunks/0254035b683c620221bc8645b19b4b78d59e7e24.e9ba235ed20e568c372e.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/studio/list": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/75fc9c18.19556d0bdea1d34cc86c.js",
"static/chunks/252f366e.f4c68bb488fa88229b73.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/css/1d9d4c0073a2ad420406be12a052fb0706641392_CSS.3b607f8a.chunk.css",
"static/chunks/1d9d4c0073a2ad420406be12a052fb0706641392_CSS.ae226c74e10a6a4b10b8.js",
"static/chunks/ef650c354c32d40407880a1b7d370a58f1a12ea2.00a65c7104961bdb8e6a.js",
"static/chunks/fddc9079040d46a3f61f5f3acff1bdd3d907dd3e.e630407a27815ee14f2e.js",
"static/chunks/e05173fefa664be4dd9a043407ebde962cd6df43.576c419f5798d4c3323f.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/studio/upload": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/css/1d9d4c0073a2ad420406be12a052fb0706641392_CSS.3b607f8a.chunk.css",
"static/chunks/1d9d4c0073a2ad420406be12a052fb0706641392_CSS.ae226c74e10a6a4b10b8.js",
"static/chunks/e05173fefa664be4dd9a043407ebde962cd6df43.576c419f5798d4c3323f.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/support": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/359540dcbb6e24a567b648fffa3ff60e0db92c56.2d667fcfad0ef88b061c.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/team": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/359540dcbb6e24a567b648fffa3ff60e0db92c56.2d667fcfad0ef88b061c.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
],
"/terms": [
"static/runtime/webpack-85402d0d67e18a3d3cb8.js",
"static/chunks/framework.be2f8eec1d0bd8e51815.js",
"static/chunks/commons.8863f832be35f69c65a3.js",
"static/chunks/ca9dbae95859cd1eabf00f974f1759b847b48a50.3509683e3b73e4237483.js",
"static/chunks/359540dcbb6e24a567b648fffa3ff60e0db92c56.2d667fcfad0ef88b061c.js",
"static/css/styles.fac2d418.chunk.css",
"static/chunks/styles.e3eda856074099fb3410.js",
"static/runtime/main-c94a9065ea31aac1728c.js"
]
}
}
Mmh strange, none of those chunks seem to be referenced in the build-manifest.
Could you grep for any of them in the .next directory, e.g.
grep -nr 'static/runtime/webpack-c212667a5f965e81e004.js' .next/
Hopefully we can find if the chunk is being referenced in any manifest within .next/.
Also, you can pin to an earlier version of serverless-next.js that works for you whilst I investigate this,
component: [email protected] # for example
...
No, when i use this command, i have no results (for each file)
I test with a previous version, and it works (1.10.0)
Thank !! :)
@danielcondemarin I bump into the same situation and your solution save my day!
But I wonder that seems those chunks not in .next/build-manifest.json will never been upload, we can only use previous version of serverless-next to prevent this issue for now ?
@zizizheng For now pin the version but I'm keen on getting to the bottom of this. I wonder if this is only affecting next.configs with some sort of specific configuration.
https://github.com/danielcondemarin/serverless-next.js/tree/master/packages/s3-static-assets is responsible for reading the build-manifest and uploading chunks etc. to S3.
Could you share which chunks you are missing and your build-manifest please?
Also if someone could give me a simple repro I will get this fixed ASAP
Hey folks 馃憢 Some good news, just published a fixed for this on [email protected]! 馃帀
Most helpful comment
Hey folks 馃憢 Some good news, just published a fixed for this on
[email protected]! 馃帀