Skip to content

Chore: Sync fuzzer: Re-use the same CLI process for commands run on the same client #12913

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

Conversation

personalizedrefrigerator
Copy link
Collaborator

@personalizedrefrigerator personalizedrefrigerator commented Aug 8, 2025

Summary

Note

The changes included in this pull request were originally made as a part of #12741, to help debug fuzzer failures.

This pull request adjusts how commands are run by the sync fuzzer.

  • Previously, one CLI process was created for each command.
    • Commands were run with yarn start-no-build (with arguments specifying the command), which starts an instance of the CLI application.
  • Previously, the web clipper server ran in a background process.
    • As a result, it was possible for multiple same-profile CLI processes to run at the same time. This could cause the fuzzer to behave unexpectedly.

This pull request updates the fuzzer to run all commands for a Client in the same CLI application process, including the web clipper.

To simplify debugging, this pull request also adjusts the fuzzer's behavior when an issue is detected:

  • This pull request adds logic to:
    • Bring the background CLI process for a Client to the foreground when the fuzzer stops.
    • Print a transcript of all interactions with a particular client.

See #12741.

Supporting changes

  • Client.sync is now retried after a delay on failure.
    • By avoiding restarting the CLI application with each fuzzer command, this pull request improved the performance of the sync fuzzer. With the performance improvement came additional fuzzer failures. These failures seem to resolve if actions are retried after a delay (perhaps some background task on the server needs time to complete?).
  • The batch CLI command, when the file name is set to -, has been updated to accept input from stdin.
    • This each fuzzer Client object to start a single background CLI application and communicate with it through process.stdin and process.stdout.
  • The server CLI command has been updated to support --exit-early and --quiet options.
    • The server command starts the webclipper API server.
    • The --exit-early option allows the command to return while the server is still running. This allows the API server to be started from the main CLI process, without blocking other commands from running.
    • The --quiet option prevents the webclipper logger from sending warning, debug, and info-level to stdout. This log information is still sent to log-clipper.txt.
      • Without the --quiet flag, the webclipper logs would be included in the output of the batch command. The fuzzer reads this output to determine, for example, the content of notes.

each command

This commit is an attempt to improve sync fuzzer performance and work around random failures. It's currently failing after a few steps of the sync fuzzer due to a "Master key not loaded" error.
I'm not sure why this wasn't caught by the linter during commit...
@personalizedrefrigerator
Copy link
Collaborator Author

Some of the changes to app-cli/app.ts should be refactored to make it clearer why the changes are necessary. I'm closing this pull request until the app.ts refactoring is done..

Comment on lines +19 to +20
['--exit-early', 'Allow the command to exit while the server is still running. The server will still stop when the app exits. Valid only for the `start` subcommand.'],
['--quiet', 'Log less information to the console. More verbose logs will still be available through log-clipper.txt.'],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
['--exit-early', 'Allow the command to exit while the server is still running. The server will still stop when the app exits. Valid only for the `start` subcommand.'],
['--quiet', 'Log less information to the console. More verbose logs will still be available through log-clipper.txt.'],
['--exit-early', _('Allow the command to exit while the server is still running. The server will still stop when the app exits. Valid only for the `start` subcommand.')],
['--quiet', _('Log less information to the console. More verbose logs will still be available through log-clipper.txt.')],

These commands are mostly intended for debugging. However, since they have help text, it may make sense to allow the help text to be localized.

@laurent22 laurent22 merged commit 46ab00b into laurent22:dev Aug 10, 2025
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants