megahertz / electron-log

Simple logging module Electron/Node.js/NW.js application. No dependencies. No complicated configuration.
MIT License
1.3k stars 127 forks source link

On Windows (no bug on Mac) sometimes see JavaScript error when app starts using log. #402

Open kmackey1 opened 7 months ago

kmackey1 commented 7 months ago

Sometimes when my Windows app starts, I will see 5 JavaScript errors with "EBUSY: resource busy or locked, open 'C:\Users\kmackey\product\logs\main.log'"

Using Process Monitor, usually, but not always, I see MsSense.exe (the main service executable for Defender for Endpoint, the service is running as a service with the name SENSE) accessing the file. I tried adding the log file as an exception to Defender, but I still see the errors.

Also in Process Monitor, I see some of my app's operations resulting in sharing violations, though they don't always result in the JavaScript errors. Here are the operations that seem to result in the errors (from different app runs):

Desired Access: Generic Read/Write, Disposition: OverwriteIf, Options: Synchronous IO Non-Alert, Attributes: N, ShareMode: Read, Write, Delete, AllocationSize: 0

Desired Access: Append Data/Add Subdirectory/Create Pipe Instance, Write EA, Read Attributes, Write Attributes, Read Control, Synchronize, Disposition: OpenIf, Options: Synchronous IO Non-Alert, Attributes: N, ShareMode: Read, Write, Delete, AllocationSize: 0

megahertz commented 7 months ago

It looks like you have a few different instances of your app running. For such a case, it's better to use a different log file name for each instance.

kmackey1 commented 7 months ago

I should have added that this problem is not happening on the macOS version of the app. Only Windows.