i found that the event listener may have been configured incorrectly
the listener was attach on websocket connect event, this will cause of reattachment of a new listener every time we refresh the page while leaving the older one still exists thus hogging up the memory
it doesn't remove the listener on websocket connection close
i made this changes in attempt to fix it
move up the event listener for the Cap library, i think it's better to put it on the global level so that we don't create a listener every time we connected
changing the websocket handle event from onconnected to onlistening, the onconnected event is called every time we made connection to the websocket that includes page refresh while the onlistening event is only called after the connection is established meaning even after we close the browser tab or refresh it, it will stay alive as long as the connection is still on.
adding an event remover when the websocket connection is closed, this will free up memory as it will not leave any stale connection
i have tried it on my machine and this fixed it
hope you can review and verify this, cheers :wave:
@Zeldruck I think i may have found the cause for issue https://github.com/Zeldruck/Albion-Online-ZQRadar/issues/3
i found that the event listener may have been configured incorrectly
i made this changes in attempt to fix it
Cap
library, i think it's better to put it on the global level so that we don't create a listener every time we connectedonconnected
toonlistening
, the onconnected event is called every time we made connection to the websocket that includes page refresh while the onlistening event is only called after the connection is established meaning even after we close the browser tab or refresh it, it will stay alive as long as the connection is still on.i have tried it on my machine and this fixed it hope you can review and verify this, cheers :wave: