still finish item when not returning from sync callback

This commit is contained in:
Bruno Windels 2021-11-17 10:42:54 +01:00
parent d01271fb15
commit 1942c31eff

View file

@ -69,6 +69,7 @@ export abstract class BaseLogger {
} }
_run<T>(item: ILogItem, callback: LogCallback<T>, logLevel: LogLevel, wantResult: true, filterCreator?: FilterCreator): T; _run<T>(item: ILogItem, callback: LogCallback<T>, logLevel: LogLevel, wantResult: true, filterCreator?: FilterCreator): T;
// we don't return if we don't throw, as we don't have anything to return when an error is caught but swallowed for the fire-and-forget case.
_run<T>(item: ILogItem, callback: LogCallback<T>, logLevel: LogLevel, wantResult: false, filterCreator?: FilterCreator): void; _run<T>(item: ILogItem, callback: LogCallback<T>, logLevel: LogLevel, wantResult: false, filterCreator?: FilterCreator): void;
_run<T>(item: ILogItem, callback: LogCallback<T>, logLevel: LogLevel, wantResult: boolean, filterCreator?: FilterCreator): T | void { _run<T>(item: ILogItem, callback: LogCallback<T>, logLevel: LogLevel, wantResult: boolean, filterCreator?: FilterCreator): T | void {
this._openItems.add(item); this._openItems.add(item);
@ -108,11 +109,12 @@ export abstract class BaseLogger {
if (wantResult) { if (wantResult) {
return result; return result;
} }
} } else {
if(wantResult) {
finishItem(); finishItem();
if(wantResult) {
return result; return result;
} }
}
} catch (err) { } catch (err) {
finishItem(); finishItem();
if (wantResult) { if (wantResult) {