Skip to content
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

[rush-lib] Ensure async telemetry hooks flush during error report #4666

Merged

Conversation

MichaelSitter
Copy link

@MichaelSitter MichaelSitter commented Apr 26, 2024

Summary

Hey team, I raised a question in Zulip about an issue with custom plugins using the the flushTelemetry hook:

https://rushstack.zulipchat.com/#narrow/stream/262513-general/topic/flushTelemetry.20hook.20receives.20no.20data.20for.20failed.20operations/near/432975837

Summarizing here, RushCommandLineParser doesn't wait for the flushTelemetry async tasks to finish for processes which ended in failure.

Details

I created a reproduction for this issue here, with a really simple plugin that just taps the telemetry and re-writes it to a custom file. You should be able to see the following:

  • rush build --to rush-flush-telemetry-example-plugin: Task succeeds, and the custom telemetry file gets written with the telemetry report.
  • rush build --to my-app: Task fails, and the custom file gets written but contains no data.

We did a little more digging & it looks like the tap hook actually works, its just the async hooks that aren't getting processed correctly. The approach I used is moving the process exit into the finally of ensureFlushedAsync. I think this is probably the right behavior, but this is a change in behavior for failed operations since it'll delay the process terminating until the telemetry hooks can be safely flushed. If this isn't an acceptable change in behavior, could we consider supporting this behind a feature flag? Or if there is a better approach I'm missing very open to suggestions. 🙇

How it was tested

There is a new test file I added, RushCommandLineParserFailureCases which is separate from the existing test file to avoid the mocking imports. This necessitated moving some of the test setup code into another file so it could be reused.

Impacted documentation

None, this addresses an issue with the native telemetry.

@MichaelSitter MichaelSitter force-pushed the patch-failed-operation-telemetry-flush branch 2 times, most recently from bb878c1 to 35d5f7c Compare April 27, 2024 00:05
@MichaelSitter
Copy link
Author

@microsoft-github-policy-service agree company="DoorDash"

@MichaelSitter MichaelSitter force-pushed the patch-failed-operation-telemetry-flush branch 5 times, most recently from 5c62714 to 9b6e54b Compare May 8, 2024 23:40
@MichaelSitter MichaelSitter marked this pull request as ready for review May 9, 2024 00:07
@MichaelSitter MichaelSitter force-pushed the patch-failed-operation-telemetry-flush branch 2 times, most recently from cbf220d to 442278b Compare May 10, 2024 17:30
@MichaelSitter MichaelSitter force-pushed the patch-failed-operation-telemetry-flush branch from 442278b to ed4dba5 Compare May 10, 2024 18:13
…operation-telemetry-flush

# Conflicts:
#	libraries/rush-lib/src/cli/test/RushCommandLineParser.test.ts
…nd is already running" even though the operation was successful
@octogonz octogonz enabled auto-merge May 14, 2024 05:36
@octogonz octogonz merged commit c29ab58 into microsoft:main May 14, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

None yet

3 participants