Skip to content

[MV3 Debug Extension] Compile extension with Dart instead of shell script #1954

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

Merged
merged 10 commits into from
Feb 14, 2023

Conversation

elliette
Copy link
Contributor

Work towards #1724, #1950

@elliette elliette requested a review from annagrin February 13, 2023 19:00
@elliette elliette changed the title Compile extension with Dart instead of shell script [MV3 Debug Extension] Compile extension with Dart instead of shell script Feb 13, 2023
Copy link
Contributor

@annagrin annagrin left a comment

Choose a reason for hiding this comment

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

Thanks Elliott, added some comments

void logOutput(ProcessResult result) {
final output = result.stdout;
final outputList = output is List ? output : [output ?? ''];
print(outputList.map((output) => '$output').join('\n'));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we switch to using transformers on the stream to listen to lines instead and logging them one by one? That way we can see the output in progress, even if the process never ends, for example. Also it will allow us to fail early if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at the documentation:

"Use the static start and run methods to start a new process. The run method executes the process non-interactively to completion. In contrast, the start method allows your code to interact with the running process."

Process.start returns a Process with stdout and stderr streams that can be listened to. I think it makes more sense to use Process.run here.

),
);
logInfo('Updating manifest.json in /compiled directory.');
logOutput(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add printing on errors, for example if the exist code is not 0? Or maybe return the exit code from run so the caller can check it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added, now checking if the exit code is not 0, and is so printing the stderr.

}

void logOutput(ProcessResult result) {
final output = result.stdout;
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably need to log the stderr as well.

Suggestion - use transformers to listen to both and use a logger to report severe errors on failures (for example, any message from stderr, non-0 exit codes, or [SEVERE] output on stdout)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Logging stderr if the exit code is not 0, and also terminating the entire process with that exit code.

elliette added a commit to elliette/webdev that referenced this pull request Feb 13, 2023
Copy link
Contributor

@annagrin annagrin left a comment

Choose a reason for hiding this comment

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

Thanks Elliott, left some small comments

);
final updateExitCode = await _handleProcess(updateStep);
// Terminate early if updating dev files failed:
if (updateExitCode != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

return updateExitCode?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, can we log that the process exited abnormally?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updateExitCode is being returned, and logging happens in main (line 29-30)

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant that this logic (lines 53-57) can be simplified to just "return updateExitCode`, but that is optional

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, done

);
final updateExitCode = await _handleProcess(updateStep);
// Terminate early if updating dev files failed:
if (updateExitCode != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I meant that this logic (lines 53-57) can be simplified to just "return updateExitCode`, but that is optional

}

void logWarning(String message) {
print('[WARNING] $message');
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional - should we just use a logger(from package:logging/logging.dart) instead of printing?

Copy link
Contributor

@annagrin annagrin Feb 14, 2023

Choose a reason for hiding this comment

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

Maybe change [WARNING] to [ERROR], to indicate irrecoverable failure?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now writing to sdout/stderr following example in https://dart.dev/tutorials/server/cmdline (package:logging/logging.dart wasn't logging to console)

Copy link
Contributor

@annagrin annagrin left a comment

Choose a reason for hiding this comment

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

LGTM!

@elliette elliette merged commit 464a8eb into dart-lang:master Feb 14, 2023
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