-
Notifications
You must be signed in to change notification settings - Fork 57
Record more error details on CLI failure #2483
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
Record more error details on CLI failure #2483
Conversation
📊 Performance Test ResultsComparing 771f78e vs trunk site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change |
| child.on( 'exit', ( code ) => { | ||
| capturedExitCode = code; |
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.
I removed the exit event handler, because it's redundant. The close event already provides the same params as the exit event.
|
|
||
| function appQuitHandler() { | ||
| const pid = child.pid; | ||
| child.removeAllListeners(); |
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.
This is unlikely to have any discernible effect, but it still makes sense in principle: this function runs before we quit the app. It kills the child process with a SIGTERM signal. If we initiated the process shutdown and the app is quitting anyway, then we don't need to listen for any more events on child
sejas
left a comment
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.
| } | ||
|
|
||
| async delete( deleteFiles: boolean ): Promise< void > { | ||
| async delete( trashFiles: boolean ): Promise< void > { |
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.
Renaming the trashFiles parameter seems not related to this PR but it's ok to keep it.
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.
Yeah, I should've commented on that, but that was intentional on my part. Just clarifies what the param does 👍
gcsecsey
left a comment
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.
| } | ||
|
|
||
| child.on( 'close', ( code ) => { | ||
| child.on( 'close', ( exitCode, signal ) => { |
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.
As a general FYI, here's from the Node.js docs:
If the process exited,
codeis the final exit code of the process, otherwisenull. If the process terminated due to receipt of asignal, signal is the string name of the signal, otherwisenull. One of the two will always be non-null.
| export type CliCommandResult = { | ||
| stdout: string; | ||
| stderr: string; | ||
| exitCode: number; |
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 value of exitCode is now implicit based on whether we emit a success or failure event.





Related issues
Proposed Changes
After the 1.7.0 launch, we've seen an increased number of
Failed to start serverandFailed to create servererrors. We know this stems from the CLI launch, and the errors are captured in Sentry, but we don't record enough details to know exactly what's going on.This PR fixes that by:
CliCommandEventEmitter'sfailureevent to contain a new custom error class in the payload.CliCommandError) captures the last error message sent over IPC (probably the most vital piece of information), stderr, stdout, the process's exit code, or the type of signal that interrupted the process.output: 'capture'config toexecuteCliCommand. If something unexpected is printed to stderr or stdout in the child process, we will now capture it, too.Testing Instructions
cli/commands/site/start.tsthat just throws an error, likethrow new Error( 'TEST ERROR' );npm startPre-merge Checklist