zwave-js / zwave-js-ui

Full featured Z-Wave Control Panel UI and MQTT gateway. Built using Nodejs, and Vue/Vuetify
https://zwave-js.github.io/zwave-js-ui
MIT License
947 stars 203 forks source link

Error while fetching store files: EPERM #2937

Open jriker1 opened 1 year ago

jriker1 commented 1 year ago

Checklist

Deploy method

PKG executable

Z-Wave JS UI version

8.8.0

ZwaveJS version

10.4.0

Describe the bug

Not sure if it was when archiving but have Z-WaveJS UI running on Windows 2022 with Hyper-V role. There is a log from teh 29th in the log folder as of 2/1 and ther eis also a tar.gz file for that day. I can't access that log file or change ownership. When I go to the Store tab I get:

Error while fetching store files: EPERM: operation not permitted, lstat 'E:\Z-WaveJSUI\store\logs\zwavejs_2023-01-29.log'

I have since deleted that log file but the system is still complaining about it when I open up the Z-WaveJS UI > Store location again fresh in a browser.

To Reproduce

Launch Z-WaveJS UI and click on Store.

Expected behavior

It shows a tree of files/folders.

Additional context

No response

robertsLando commented 1 year ago

I'm not a windows expert but how did you start zui? It could be you runned it with admin privileges and that created that file, try to right click on the file to check its ownership and fix it. Also be sure you are not running zui as administrator

jriker1 commented 1 year ago

I am running the application as a domain admin so anything being done with that executable would be with that account. It's running with NMMS and set to run as my domain user. That file is a log file that ZUI creates and looks like when it archives it at night to a GZ file it does something to the original file and it fails to be removed. When I try and view the permissions on that file it says there is no owner. Happened again when I tried to look at the logs thru the GUI today.

Some images if it helps any:

Error message on ZUI GUI: error

You know maybe that's not the root problem. If you look at the above image, that is yesterday's file, which guess is now a zwavejs_2023-02-01.log.gz file. Looks like it's still trying to find yesterday's log? Note I did notice the logs seem to be in GMT so not sure if there is anything there. Not sure how ZUI parses that folder and why it's erroring vs displaying what's there.

When I posted the original issue the .log file was still there just not accessible.

robertsLando commented 1 year ago

I have submitted a fix for this, at least it should not throw, the problem is that file seems is still present but when I try to get stats that error is thrown, no clue why BTW, maybe the log rotation delete doesn't completely delete the file and a dead reference remains in memory, no clue as cannot repro this on linux system

jriker1 commented 1 year ago

Odd, next day it's still complaining about the 2023-02-01.log file. Figured it would start complaining about 2023-02-02 but looks like there are no new log files being generated. Below is what I see at 7:53AM on 2/3/2023 CST. image

Note I am on the following releases now.

zwave-js-ui: 8.8.3 zwave-js: 10.5.5

The above may have fixed some other issues I was having but not this one. Don't want to say for sure as I'm superstitious that way.

spudwebb commented 1 week ago

I'm having the same problem, ZWave JS UI running on windows as admin. Everyday at midnight I get the following error, which then repeats itself every hour:

2024-09-11 23:18:03.519 DEBUG APP: [session-file-store] Deleting expired sessions
2024-09-11 23:18:03.566 INFO LOGGER: Cleaning up log files...
2024-09-11 23:59:59.697 INFO Z-WAVE: Next update scheduled for: Thu Sep 12 2024 00:00:00 GMT-0400 (Eastern Daylight Time)
Logging to file:
        C:\Program Files (x86)\HomeSeer HS4\Data\ZWavePlus\zwave-js-ui\store_7e62acad-7dac-4c20-b383-5d1008aaac93\logs\zwavejs_2024-09-12.log
2024-09-12 00:00:00.229 INFO Z-WAVE: Next update scheduled for: Fri Sep 13 2024 00:00:00 GMT-0400 (Eastern Daylight Time)
2024-09-12 00:18:03.417 DEBUG APP: [session-file-store] Deleting expired sessions
2024-09-12 00:18:03.479 INFO LOGGER: Cleaning up log files...
2024-09-12 00:18:03.487 ERROR LOGGER: Error getting file stats: EPERM: operation not permitted, stat 'C:\Program Files (x86)\HomeSeer HS4\Data\ZWavePlus\zwave-js-ui\store_7e62acad-7dac-4c20-b383-5d1008aaac93\logs\z-ui_2024-09-11.log'
Error: EPERM: operation not permitted, stat 'C:\Program Files (x86)\HomeSeer HS4\Data\ZWavePlus\zwave-js-ui\store_7e62acad-7dac-4c20-b383-5d1008aaac93\logs\z-ui_2024-09-11.log'
2024-09-12 01:18:03.374 DEBUG APP: [session-file-store] Deleting expired sessions
2024-09-12 01:18:03.437 INFO LOGGER: Cleaning up log files...
2024-09-12 01:18:03.440 ERROR LOGGER: Error getting file stats: EPERM: operation not permitted, stat 'C:\Program Files (x86)\HomeSeer HS4\Data\ZWavePlus\zwave-js-ui\store_7e62acad-7dac-4c20-b383-5d1008aaac93\logs\z-ui_2024-09-11.log'
Error: EPERM: operation not permitted, stat 'C:\Program Files (x86)\HomeSeer HS4\Data\ZWavePlus\zwave-js-ui\store_7e62acad-7dac-4c20-b383-5d1008aaac93\logs\z-ui_2024-09-11.log

It seems that after ZUI archives the z-ui log file as a gz file, it fails to delete the log file and messes up the permissions on it. I cannot open it (z-ui_2004-09-11.log) from windows explorer, but I can open the log file for the current day (z-ui_2024-09-12.log) just fine.

Also, note that it only happens for the z-ui log files, the zwavejs log files don't have this problem.

Can this issue be reopened?

robertsLando commented 1 week ago

hi @spudwebb, the log rotation is automatically handeld by another library @zwave-js/winston-daily-rotate-file and I'm aware of some issues related to that expecially when it comes to delete files, in fact I have integrated my own handler to clean up files. no clue if this is a known one.

cc @AlCalzone @Apollon77

AlCalzone commented 1 week ago

@robertsLando zwave-js has switched the file rotator back to the official version a while back. 5.0.0 should be fixed AFAIK.

robertsLando commented 1 week ago

@AlCalzone Latest version on NPM is still 4.5.6-1: https://www.npmjs.com/package/@zwave-js/winston-daily-rotate-file

AlCalzone commented 1 week ago

Not the scoped/forked package. The original one: https://www.npmjs.com/package/winston-daily-rotate-file The forked repo is obsoleted/archived now.

robertsLando commented 1 week ago

LOL nice to know 😆 Does it fixes the bug related to files not being deleted? I know it used to loose the track of files on every startup so they remain there forever

AlCalzone commented 1 week ago

I don't know. @apollon77 does it?

Apollon77 commented 1 week ago

I think not. I did not found time to look into it.

robertsLando commented 1 week ago

For now I have merged my pr to remove the obsolete @zwave-js package, let's see if the bug reported here is fixed then or not