Skip to content

Commit

Permalink
fix(app): correctly end stopwatch frame
Browse files Browse the repository at this point in the history
  • Loading branch information
marcj committed Oct 30, 2023
1 parent 958baae commit 86be2e1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/app/src/oclif.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ export function buildOclifCommand(

const frame = stopwatch ? stopwatch.start(name + '(' + label + ')', FrameCategory.cli, true) : undefined;

const execute: Function = controller.controller ? controller.controller.prototype['execute'] : controller.callback;
const thisArg = controller.controller ? injector.get(controller.controller, controller.module) : undefined;

try {
const execute: Function = controller.controller ? controller.controller.prototype['execute'] : controller.callback;
const thisArg = controller.controller ? injector.get(controller.controller, controller.module) : undefined;

if (frame) {
exitCode = await frame.run({}, () => execute.apply(thisArg, methodArgs));
exitCode = await frame.run(() => execute.apply(thisArg, methodArgs));
} else {
exitCode = await execute.apply(thisArg, methodArgs);
}
Expand All @@ -196,6 +196,7 @@ export function buildOclifCommand(
});
throw error;
} finally {
if (frame) frame.end();
await eventDispatcher.dispatch(onAppShutdown, { command: name, parameters: parameterValues, injector });
}
if (typeof exitCode === 'number') return exitCode;
Expand Down

0 comments on commit 86be2e1

Please sign in to comment.