-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(next-server): 'quiet' setting delegate for custom server #64512
fix(next-server): 'quiet' setting delegate for custom server #64512
Conversation
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, could we add a test for this similar to our custom server test?
@ijjk I wrote this in the PR description. I tried it in exact this spec, but I failed to get the |
Could you push the test you attempted to add and we can work from there? |
it('should not log any error messages when server is started with "quiet" setting', async () => { | ||
await next.render(`/error`) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ijjk My first impl. was here: https://github.com/vercel/next.js/blob/canary/test/integration/custom-server/test/index.test.js That was super simple. But not for production mode :(
- how do I 'customize' the custom-server? via env vars? But how do I 'set' them?
- how do I get the
stderr
messages like here?:onStderr(msg) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They can be set via the env
field next to startCommand
then the CLI output can be accessed via next.cliOutput
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ijjk Much appreciated for the help. I added two test cases:
quite: true
-> no logging- default
quite
-> logging
@@ -2,12 +2,13 @@ const { createServer } = require('http') | |||
const { parse } = require('url') | |||
const next = require('next') | |||
const getPort = require('get-port') | |||
const quiet = process.env.USE_QUIET === 'true' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from here:
const { createServer } = require(process.env.USE_HTTPS === 'true' |
Info
I did not create a GitHub issue, but this PR for fixing the issue. Hope that's okay.
The bug
We run a 'normal' custom server described here: https://nextjs.org/docs/pages/building-your-application/configuring/custom-server
The
quiet
settings is missed in some deeper Next.js internal api calls. For that reason, the setting did not work at all. This works only in production mode.Testing
I tried to implement a test in
/test/production/custom-server
but I failed to get thestderr
messages. When someone give me some guidance, I will add a new test.Here are some criteria:
quiet: true
settingexport const getServerSideProps = () => { throw new Error('failed') }
stderr
messagesI tested the fix in our project by editing the files in
node_modules
-- it worked.Background
We upgrade our project from next
13.3.4
to14.2.0
and saw this regression. I can not tell in which version this bug was added. We run a Next.js + 'custom server' + Docker setup. Because we have a lot of traffic, we need to suppress the standard Next.js logging and using our own logging.