-
Notifications
You must be signed in to change notification settings - Fork 607
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 (followup) #4953
base: main
Are you sure you want to change the base?
Changes from all commits
2152622
e3647d3
a5cce4c
ae8683e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@rushstack/heft", | ||
"comment": "Require a logging name for every operation.", | ||
"type": "patch" | ||
} | ||
], | ||
"packageName": "@rushstack/heft" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@rushstack/operation-graph", | ||
"comment": "(BREAKING API CHANGE) Require an operationName for every operation to improve logging.", | ||
"type": "minor" | ||
} | ||
], | ||
"packageName": "@rushstack/operation-graph" | ||
} |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -31,7 +31,7 @@ export interface IWatchLoopOptions { | |||||||
/** | ||||||||
* Logging callback when a run is requested (and hasn't already been). | ||||||||
*/ | ||||||||
onRequestRun: (requestor?: string) => void; | ||||||||
onRequestRun: (requestor: string) => void; | ||||||||
/** | ||||||||
* Logging callback when a run is aborted. | ||||||||
*/ | ||||||||
|
@@ -45,7 +45,7 @@ export interface IWatchLoopOptions { | |||||||
*/ | ||||||||
export interface IWatchLoopState { | ||||||||
get abortSignal(): AbortSignal; | ||||||||
requestRun: (requestor?: string) => void; | ||||||||
requestRun: (requestor: string) => void; | ||||||||
} | ||||||||
|
||||||||
/** | ||||||||
|
@@ -60,7 +60,7 @@ export class WatchLoop implements IWatchLoopState { | |||||||
private _isRunning: boolean; | ||||||||
private _runRequested: boolean; | ||||||||
private _requestRunPromise: Promise<string | undefined>; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And on line 267. |
||||||||
private _resolveRequestRun!: (requestor?: string) => void; | ||||||||
private _resolveRequestRun!: (requestor: string) => void; | ||||||||
|
||||||||
public constructor(options: IWatchLoopOptions) { | ||||||||
this._options = options; | ||||||||
|
@@ -147,7 +147,7 @@ export class WatchLoop implements IWatchLoopState { | |||||||
} | ||||||||
} | ||||||||
|
||||||||
function requestRunFromHost(requestor?: string): void { | ||||||||
function requestRunFromHost(requestor: string): void { | ||||||||
if (runRequestedFromHost) { | ||||||||
return; | ||||||||
} | ||||||||
|
@@ -192,9 +192,12 @@ export class WatchLoop implements IWatchLoopState { | |||||||
|
||||||||
try { | ||||||||
status = await this.runUntilStableAsync(abortController.signal); | ||||||||
// ESLINT: "Promises must be awaited, end with a call to .catch, end with a call to .then ..." | ||||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||||||||
this._requestRunPromise.finally(requestRunFromHost); | ||||||||
this._requestRunPromise | ||||||||
// the reject callback in the promise is discarded so we ignore errors | ||||||||
.catch(() => {}) | ||||||||
Comment on lines
+196
to
+197
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this behavior correct/expected? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the watchloop is using a deferred promise pattern, but only binds the rushstack/libraries/operation-graph/src/WatchLoop.ts Lines 264 to 266 in ca6e96b
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic here is wrong. |
||||||||
.finally(() => { | ||||||||
requestRunFromHost('runIPCAsync'); | ||||||||
}); | ||||||||
} catch (err) { | ||||||||
status = OperationStatus.Failure; | ||||||||
return reject(err); | ||||||||
|
@@ -225,7 +228,7 @@ export class WatchLoop implements IWatchLoopState { | |||||||
/** | ||||||||
* Requests that a new run occur. | ||||||||
*/ | ||||||||
public requestRun: (requestor?: string) => void = (requestor?: string) => { | ||||||||
public requestRun: (requestor: string) => void = (requestor: string) => { | ||||||||
if (!this._runRequested) { | ||||||||
this._options.onRequestRun(requestor); | ||||||||
this._runRequested = true; | ||||||||
|
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 also a breaking API change. Is this rename necessary?
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.
I feel this change is beneficial to ensure we are more explicit in the naming. The purpose of
name
is easily lost outside of theoperation-graph
lib context. Specifically as downstream libs use this interface to implement custom operations like the heftTaskOperationRunner
.