Skip to content

Commit

Permalink
chore: handle error in case of heap statistics error
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayachand committed Jul 1, 2024
1 parent 39b9589 commit 9335090
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/util/customTransformer-v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ async function userTransformHandlerV1(
throw err;
} finally {
logger.debug(`Destroying IsolateVM`);
const { used_heap_size } = isolatevm.isolate?.getHeapStatisticsSync();
let used_heap_size = 0;
try {
used_heap_size = isolatevm.isolate.getHeapStatisticsSync()?.used_heap_size || 0;
} catch (err) {
logger.error(`Error encountered while getting heap size: ${err.message}`);

Check warning on line 96 in src/util/customTransformer-v1.js

View check run for this annotation

Codecov / codecov/patch

src/util/customTransformer-v1.js#L96

Added line #L96 was not covered by tests
}
isolatevmFactory.destroy(isolatevm);
// send the observability stats
const tags = {
Expand Down

0 comments on commit 9335090

Please sign in to comment.