Next.js Discord

Discord Forum

build fails with error "Error: Jest worker encountered 1 child process exceptions, exceeding retry "

Answered
Arboreal ant posted this in #help-forum
Open in Discord
Arboreal antOP
I've read a few threads on this and they say it has something to do with mysql, i recently migrated to mysql from mongodb and this error started showing up when i try to build my app, i haven't installed jest so dont know why im getting this error
Error: Jest worker encountered 1 child process exceptions, exceeding retry limit
Answered by Arboreal ant
i switched to next canary, that fixed it so it must be a problem with the stable nextjs version
View full answer

27 Replies

Arboreal antOP
bump
Arboreal antOP
Bump
I was getting this as well at one point, I deleted my node modules folder and next folxer closed vscode completely, then reinstalled everything
Arboreal antOP
i noticed this happens when i use mysql2
still dont know how to fix it
Arboreal antOP
Bump
hello, what version(node & next) are you using ?
@averydelusionalperson I believe, this error is similar to this: https://discord.com/channels/752553802359505017/1224686590438408272/1224688098344964170
Arboreal antOP
The solution there is to downgrade next to v13, and I can't do that
@averydelusionalperson hello, what version(node & next) are you using ?
Arboreal antOP
i am using node v20.11.1 and next 14.1.4
@Arboreal ant i am using node v20.11.1 and next 14.1.4
try adding this to next.config
/** @type {import('next').NextConfig} */
const nextConfig = {
    experimental: {
        serverComponentsExternalPackages: ['mysql2']
    }
};
@Ray try adding this to next.config ts /** @type {import('next').NextConfig} */ const nextConfig = { experimental: { serverComponentsExternalPackages: ['mysql2'] } };
Arboreal antOP
same error
Error: Jest worker encountered 1 child process exceptions, exceeding retry limit
@Ray try adding this to next.config ts /** @type {import('next').NextConfig} */ const nextConfig = { experimental: { serverComponentsExternalPackages: ['mysql2'] } };
Arboreal antOP
this is the full error
> Build error occurred
Error: Jest worker encountered 1 child process exceptions, exceeding retry limit
    at ChildProcessWorker.initialize (C:\Users\Desktop\project\node_modules\next\dist\compiled\jest-worker\index.js:1:11580)
    at ChildProcessWorker._onExit (C:\Users\Desktop\project\node_modules\next\dist\compiled\jest-worker\index.js:1:12545)
    at ChildProcess.emit (node:events:530:35)
    at ChildProcess._handle.onexit (node:internal/child_process:294:12) {
  type: 'WorkerError'
}
@Ray are you using jest to test?
Arboreal antOP
nope
@Arboreal ant nope
could you show your package.json
@Ray could you show your package.json
Arboreal antOP
@Arboreal ant Click to see attachment
only occur on build?
could you show some code on how do you use mysql2? or is your project on github?
@Ray only occur on build?
Arboreal antOP
yes, dev works fine
@Ray could you show some code on how do you use mysql2? or is your project on github?
Arboreal antOP
import mysql from "mysql2/promise";

const pool = mysql.createPool({
  host: process.env.DB_HOST,
  user: process.env.DB_USER,
  password: process.env.DB_PASSWORD,
  database: process.env.DB_NAME,
  connectionLimit: 1,
});

let connection = null;

export async function connectDB() {
  if (!connection || connection._closed) {
    connection = await pool.getConnection();
  }
  return connection;
}
@Ray try setting `connectionLimit: 10`
Arboreal antOP
nope
@Ray try setting `connectionLimit: 10`
Arboreal antOP
i switched to next canary, that fixed it so it must be a problem with the stable nextjs version
Answer
@Arboreal ant i switched to next canary, that fixed it so it must be a problem with the stable nextjs version
yes I can't build with 14.1.4 but got a different message
@Ray yes I can't build with 14.1.4 but got a different message
Arboreal antOP
yh il stick to canary until its fixed