DiamondLightSource / cs-web-lib

Library form of control system web UI prototype
Apache License 2.0
1 stars 1 forks source link

Fix errors thrown when disconnected #20

Closed rjwills28 closed 1 year ago

rjwills28 commented 1 year ago

Fix errors thrown by the client when disconnected from the Conqil websocket. The console was full of unnecessary errors which could be logged as warnings. There was also a case where it tried to unsubscribe from a PV that it was not subscribed to and hence tried to remove a PV from a list that did not contain it throwing an error. With a page that has many PVs that are disconnected this becomes a lots of logged errors. Refer to issue #17.

rjwills28 commented 1 year ago

The way to test the second part is to run the app when not connected to Coniql and then refresh the page or wait for the screen transition to happen. In this case no subscriptions will have been made and so when it tries to unsubscribe it should no longer throw any errors (pre-fix it will do). An easy way might be to locally change the REACT_APP_CONIQL_SOCKET variable in the .env to point some dummy IP (i.e. anywhere other than the running server).

aawdls commented 1 year ago

The way to test the second part is to run the app when not connected to Coniql and then refresh the page or wait for the screen transition to happen. In this case no subscriptions will have been made and so when it tries to unsubscribe it should no longer throw any errors (pre-fix it will do). An easy way might be to locally change the REACT_APP_CONIQL_SOCKET variable in the .env to point some dummy IP (i.e. anywhere other than the running server).

Sorry what I meant here was - would it be feasible to write a unit test for

rjwills28 commented 1 year ago

Ah sorry, misunderstood. Yes that's a good idea - I'll look into that.

rjwills28 commented 1 year ago

I've added a new test to check the unsubscribe behaviour. This test would have failed before this fix.