Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat: log cluster module IPC via onelogger #120
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
base: 1.x
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
feat: log cluster module IPC via onelogger #120
Changes from all commits
42ae0daFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
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.
The environment variable check
!!process.env.EGG_CLUSTER_IPC_LOGwill evaluate totrueeven if the variable is set to the string"0"or"false". In the context of environment variables, users often expect these values to disable a feature. It is safer to explicitly check for truthy values or exclude known falsy strings.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.
The
stringifyDatafunction eagerly performsJSON.stringifyon the message data. Since this is called byformatIpcMessagebefore passing the result toipcLogger.info, the stringification overhead is incurred for every IPC message even if the logger is configured to ignoreINFOlevel messages. For the "always on" application layer logs (Points A, B, C, D), this could impact performance under high IPC load. Consider making these logs opt-in or using a lower log level likedebugto minimize default overhead.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.
Logging inside this loop is particularly expensive because
formatIpcMessage(and its internalJSON.stringify) is called for every worker in the cluster. If a message is broadcast to many workers, the same data object is stringified repeatedly. This can cause significant CPU spikes in the Master process. It is recommended to pre-calculate the data string once outside the loop or use a more efficient logging strategy for broadcasts.