write-file-atomic icon indicating copy to clipboard operation
write-file-atomic copied to clipboard

[BUG] Does not handle `undefined` return value from signal-exit's onExit() function

Open kayahr opened this issue 4 years ago • 1 comments

According to the documentation of signal-exit the onExit function always returns a function. But according to the actual source code this is not true. The function can return undefined in specific circumstances (I encounter this within Electron) and write-file-atomic fails when trying to call this undefined function.

I guess the function call should be wrapped with a null check.

kayahr avatar Oct 02 '21 12:10 kayahr

Just ran into this last night as our team was trying to ship a beta release. It is a Electron app using the electron-settings package. Local dev and electron-builder output worked. This error didn't appear to occur in our app until built via a Github workflow.

I haven't figured out why this issue occurs nor do I have time to find out. My only option is to tear it out and use something else.

[2024-09-17 09:50:03.532] [error] Error occurred in handler for 'load-stations-file': TypeError: onExit is not a function at writeFileAsync (C:\Users\user\AppData\Local\Programs\app-name\resources\app.asar\node_modules\write-file-atomic\index.js:82:31) at writeFile (C:\Users\user\AppData\Local\Programs\app-name\resources\app.asar\node_modules\write-file-atomic\index.js:164:19) at C:\Users\user\AppData\Local\Programs\app-name\resources\app.asar\node_modules\electron-settings\dist\settings.js:265:49 at new Promise () at C:\Users\user\AppData\Local\Programs\app-name\resources\app.asar\node_modules\electron-settings\dist\settings.js:263:16 at async LoadStations (C:\Users\user\AppData\Local\Programs\app-name\resources\app.asar\out\main\index.js:1499:7) at async WebContents. (node:electron/js2c/browser_init:2:77963)

rleikis avatar Sep 18 '24 05:09 rleikis