vuex-electron icon indicating copy to clipboard operation
vuex-electron copied to clipboard

bad file descriptor errors

Open michaeljpeake opened this issue 5 years ago • 6 comments

I keep getting errors, Uncaught Error: EBADF: bad file descriptor, close, that point back to the setState function in PersistedState.

I wonder if this happens when multiple mutations happen in quick succession. Is there a known limitation in this sense? Is so, might it be possible to implement some kind of debounce to prevent file issues?

michaeljpeake avatar Feb 28 '19 16:02 michaeljpeake

No way! I've just rewritten my app because I thought it was my fault. 😢 Nice to see it being fixed though 👍

NoelDavies avatar Mar 06 '19 08:03 NoelDavies

Actually, I've found the issue may actually be that both the main and renderer functions are trying to set the state on disk.

I've managed to fix it by adding an if statement that checks that the process is the main one, before trying to commit the json to disk. Seems to have fixed everything for me.

I'll create a new fork and see if this one can be merged in.

michaeljpeake avatar Mar 06 '19 11:03 michaeljpeake

I've been testing the new build of my app - and sometimes I get 10+ state updates within a second, so I think these be better off being queued and written every configurable-timeframe (eg 500ms) as I assume the debounce PR addresses.

It would definitely increase performance once the process check fix is implemented. Yes, it may cut my writes by half, but I still think I may have the same issue without the debounce PR too

What are your thoughts?

NoelDavies avatar Mar 06 '19 20:03 NoelDavies

I think that the error is caused by bug in write-file-atomic https://github.com/npm/write-file-atomic/issues/39

Easiest solution is to upgrade electron-store module to 3.3.0, which requires newer version of conf module, which requires version write-file-atomic where the bug was fixed

rtf-const avatar Jun 26 '19 09:06 rtf-const

I have tried upgrading electron/vuex-electron/write-file-atomic and tried the method by michaeljpeake, but useless. Finally I change to use ipMain = =

Just2 avatar Jul 21 '19 07:07 Just2

https://github.com/vue-electron/vuex-electron/issues/44

akodkod avatar Aug 29 '19 14:08 akodkod