interval / interval-node

The official Interval SDK for Node.
https://interval.com/docs
121 stars 13 forks source link

Handler of active page is called two times on backend rebuild #17

Closed apopant closed 1 year ago

apopant commented 1 year ago

I experience actions called two times in certain situation I have interval website is open at a slug (action) Then I modify the code and that triggers a rebuild Once rebuilt, while the frontend refreshes, and I see in BE logs that the handler for the opened view is called 2 times

I notice 2 errors in browser console when this happens first 2 lines are last logs before I trigger rebuild the error logs are during (re) connect one of the handlers seem to be (attempted) to be removed twice

image

jacobmischka commented 1 year ago

The error logs in the browser console are expected, it means your backend hadn't happened to reconnect yet the first time the page tried reconnecting. Those removing handlers logs should have been silenced, apologies, but there's nothing odd happening there (the duplicate ID isn't a problem, though it does seem odd).

I'm unable to reproduce the action starting twice on the backend: a console.log on the first line of the action is triggered only once upon reconnect. Could you provide some more information about the action and your setup that might help reproduce this?

Thanks!

apopant commented 1 year ago

We use NestJS, I don't see issues in the setup, actions registered once.

I was looking at the socket data, there are plenty of log messages there... I don't see how to extract them, don't see the same in history

here is a screenshot of the websocket log (cleared before I rebuild backend, browser is at the action page) image

here is the same page on open (just selected from dashboard, no rebuilds) image

jacobmischka commented 1 year ago

I am able to reproduce it now, thanks! Turns out it happens in Chrome but not other browsers. Looking into a fix now.

In the meantime, can I ask what version of @interval/sdk you're using? Version ^0.35.0 should drop the duplicate messages so the transaction won't be started multiple times, could you try that if you aren't already?

Thanks for reporting this bug!

jacobmischka commented 1 year ago

Er sorry about the automatic premature close. I just committed a fix for this, should be live shortly. I'll write back once it's been deployed!

jacobmischka commented 1 year ago

It should be deployed now, please write back if you still experience the issue and we'll take another look. Thanks again for your help!

apopant commented 1 year ago

I am able to reproduce it now, thanks! Turns out it happens in Chrome but not other browsers. Looking into a fix now.

I was using Edge

In the meantime, can I ask what version of @interval/sdk you're using? Version ^0.35.0 should drop the duplicate messages so the transaction won't be started multiple times, could you try that if you aren't already?

Today the issue didn't happen, also didn't see it in 0.35.2

thank you!