Premature End of Input 'realm-js'

I’m working on an offline first desktop app with electron and realm. The app opens the sync from the main process and for some reason, after a short while (maybe 20-30 mins) of the app being in background, It crashes the process giving the following errors

Apparently, this just happens if the app is not being actively used for some time. I tried looking it up but it’s very vaguely explained here without any potential fixes.

Anything understanding the error further and potential fixes will be a great help!