segfault running custom next server within jest unit test after upgrading nextjs 11 -> 12
See original GitHub issueRun next info
(available from version 12.0.8 and up)
N/A
What version of Next.js are you using?
11.1.3 + 12.0.7
What version of Node.js are you using?
16.13.1
What browser are you using?
N/A
What operating system are you using?
macOS
How are you deploying your application?
N/A
Describe the Bug
Within a custom server application there are some unit tests using the jest framework along with supertest to mimic http requests (See replication repo). This has been working as expected up until trying to upgrade to multiple 12.X nextjs versions including 12.0.0
, 12.0.1
, and 12.0.7
.
When running version 12 with a next.config.js
configuration present and a custom server with dev: false
, the jest execution exits with a segfault when calling app.prepare()
.
const app = next({
dev: false,
});
await app.prepare(); // Goes 💥
zsh: segmentation fault npm test
It is possible to workaround this issue by importing the nextjs config manually and passing it as the conf
option to the custom next application.
example workaround
const app = next({
dev: false,
conf: require('./next.config'), // this fixes the seg fault
});
await app.prepare(); // No 💥 this time
await request(app.getRequestHandler())
.get("/")
.expect(200);
Expected Behavior
I would expect this not to crash and nextjs to be able to resolve the next.config.js
automatically without the conf option
To Reproduce
I have published a public GitHub repo that reproduces the following scenarios along with setup instructions
https://github.com/Kauabunga/nextjs-replicate-segfault-custom-server-v12
- [✓] jest unit test with version 11.1.3 without a
next.config.js
- [✓] jest unit test with version 11.1.3 with a
next.config.js
- [✓] jest unit test with version 12.0.7 without a
next.config.js
- [✗] jest unit test with version 12.0.7 with a
next.config.js
- [✓] jest unit test with version 12.0.7 with a
next.config.js
with custom server optionsconf: require('next.config')
- [✗] jest unit test with version canary with a
next.config.js
andsegfault-handler
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top GitHub Comments
Same issue reported here https://github.com/vercel/next.js/issues/31162
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.