node-machine-id icon indicating copy to clipboard operation
node-machine-id copied to clipboard

Catch exceptions in exec callback to ensure Promise is rejected

Open chenhuang444 opened this issue 5 years ago • 1 comments

What

Adds try-catch block to exec callback for machineId()

Why

A Promise has an implicit try-catch reject logic. However, the callback from exec is not handled by this implicit try-catch. Thus any exceptions thrown in expose() will not be caught and the promise will not be rejected.

I noticed this when some of my users had a TypeError: Cannot read property 'replace' of undefined error on sentry

Risk

Low: simple try catch block, does not change original resolve, reject behavior

chenhuang444 avatar Jan 18 '21 05:01 chenhuang444

Resolves this issue #50

chenhuang444 avatar Jan 18 '21 05:01 chenhuang444