-
Notifications
You must be signed in to change notification settings - Fork 0
feat(plugin): use stdio instead of tcp socket for transport #66
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: main
Are you sure you want to change the base?
Conversation
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 simplifies the code a lot! I've got some remarks and a question.
| */ | ||
| private log(level: string, message: string, ...labels: string[]): void { | ||
| // Strip trailing newlines from the message | ||
| const cleanedMessage = message.replace(/\n+$/, ''); |
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.
Why would we remove newlines? Let's make the logging output recognizable to the end user (like what they already recognize in the 'normal' output).
| /** | ||
| * Abstract interface for mutation server transport implementations | ||
| */ | ||
| export interface ITransport { |
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.
It is considered a bad practice to prefix interfaces with an I in TypeScript, as there is no technical need to do so (in C#, there is, because there is no visual distinction when extending interfaces vs classes).
But this interface isn't even needed, since it is the same as StdioTransport.
| }; | ||
| write(data: string | Buffer) { | ||
| if (!this.#process?.stdin) { | ||
| throw new Error('Process stdin is not available'); |
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 unreachable code, since we're not overriding the stdio options. stdin should always exist, or Node.js isn't working correctly. I would be happy using a ! here.
| onPartialResult: (partialResult: MutationTestResult) => void, | ||
| ): Promise<MutationTestResult> { | ||
| const subscription = this.notifications | ||
| const subscription = this.transport.notifications |
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.
So we're subscribing to the notifications whenever we start a new run. What happens when the user begins multiple runs? Won't the notifications interfere with each other?
Resolves #58
BREAKING CHANGE: drop support for socket transport with mutation server