Skip to content

Commit

Permalink
clear tryCatchTarget to release reference of function for gc (#4450)
Browse files Browse the repository at this point in the history
* clear tryCatchTarget to release reference of function for gc

* refactor(tryCatch): move clean of up tryCatchTarget to finally, clean up errorObject.e on call.

* refactor(tryCatch): remove unnecessary `result` variable.
  • Loading branch information
chenxm authored and benlesh committed Jan 9, 2019
1 parent 56614ee commit 9e90db1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/internal/util/tryCatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import { errorObject } from './errorObject';
let tryCatchTarget: Function;

function tryCatcher(this: any): any {
errorObject.e = undefined;
try {
return tryCatchTarget.apply(this, arguments);
} catch (e) {
errorObject.e = e;
return errorObject;
} finally {
tryCatchTarget = undefined;
}
}

Expand Down

0 comments on commit 9e90db1

Please sign in to comment.