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

[heft] Require a logging name for every operation #4469

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

octogonz
Copy link
Collaborator

@octogonz octogonz commented Jan 2, 2024

Summary

Fixes #4467

Details

@bartvandenende-wm has proposed a simpler fix in PR #4468

However, it seems error-prone and unnecessary to allow operations to be started entirely anonymously. My PR proposes a more aggressive API change to require the name field.

👉 Let's discuss the design in the comments for issue #4467

How it was tested

Redo repro steps from #4467

Impacted documentation

None

@@ -453,6 +453,7 @@ function _getOrCreatePhaseOperation(
// Only create the operation. Dependencies are hooked up separately
operation = new Operation({
groupName: phase.phaseName,
name: `${phase.phaseName} phase`,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What is the appropriate name for a phase?

In the source code, there currently seem to be very few places that actually read the name or groupName.

Copy link
Contributor

Choose a reason for hiding this comment

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

A phase operation is setup work that runs before all tasks in the given phase, so it should indicate something about setup or initialization.

Copy link
Contributor

Choose a reason for hiding this comment

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

Currently the phase operation is only used for performing the clean.

…ration names percolate through the call graphs

- Fix spelling of "requestor" and make it non-optional
return requestRun(this.name);
return requestRun(this.operationName);
case undefined:
throw new InternalError(`The operation state is undefined`);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(Improved this error message)

@@ -20,7 +20,7 @@ export interface IOperationExecutionOptions {
parallelism: number;
terminal: ITerminal;

requestRun?: (requestor?: string) => void;
requestRun?: (requester: string) => void;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(The requester is now also non-optional)

Copy link
Contributor

Choose a reason for hiding this comment

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

The requester could ultimately be multiple layers of identifiers; I guess we can just concatenate strings, but it might be better to make this an array of hierarchy nodes (e.g. Operation, file). When Rush receives one of these messages over IPC it'll get wrapped in a further node for the Rush-level Operation.

@@ -193,7 +193,9 @@ export class WatchLoop implements IWatchLoopState {

try {
status = await this.runUntilStableAsync(abortController.signal);
this._requestRunPromise.finally(requestRunFromHost);
this._requestRunPromise.finally(() => {
requestRunFromHost('runIPCAsync');
Copy link
Collaborator Author

@octogonz octogonz Jan 9, 2024

Choose a reason for hiding this comment

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

@dmichon-msft what is the appropriate name to supply here? In the current implementation it was implicitly getting mapped to undefined.

(If we're going to be referring to requesters/operations by names, then we should provide a meaningful name in every code path, rather than printing awkward messages like "This job was started by an unknown source.")

Copy link
Contributor

Choose a reason for hiding this comment

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

If .finally is not forwarding the promise result (which is the underlying requester), use .then instead. The error code path is unreachable code, since the reject callback is discarded.

@bartvandenende-wm
Copy link
Contributor

any cycles available to cleanup this PR @octogonz? it would be great to see this fix in a future release. I'm happy to help if useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

[heft] heft watch mode always logs the re-run requestor task as unknown
3 participants