Repository navigation
Fixing Teleop crash on publish message - #882
Conversation
rodrigo-p-rodrigues
left a comment
There was a problem hiding this comment.
lgtm!
Note:
Instead of running on host mode, exposing ports worked for me:
docker run --rm -p 8765:8765 lichtblick-teleop-sim
…vertise on first render
|
So I identified the problem, trying to publish a message before advertising, still persisted on first render. Basically unadvertised was being called on the initial render so I implemented an |
|
Had to make a change on a unit test to actually transcribe what's happening. I discovered why I was only able to reproduce this bug on dev mode. Because of React Strict Mode, the component would get rendered twice making it that:
This was the reason for the bug and why I was not able to reproduce it on Prod. |
|
rodrigo-p-rodrigues
left a comment
There was a problem hiding this comment.
Tested it and the issue is fixed, which is an improvement for the users.
I think some of the existing unit tests should be reviewed at some point.



User-Facing Changes
There were cases when Teleop panel completely crashed Lichtblick because it would try to publish a message faster than topic would be advertised, with this fix this error should not happen again.
Fixes #554
Description
Problem: The publish effect and advertise effect are asynchronous and independent. When a button is clicked, the code attempts to publish a message immediately, but there's a race condition where the topic may not be fully ready yet, causing an unhandled exception that crashes the entire panel.
(I was only able to reproduce the error on Lichtblick's web version on dev mode)
Added try-catch error handling around all
context.publish()calls:So now the try and catch catches the exception instead of letting it crash the component, then
setIntreval()retries publishing the message and eventually, even if the publish fails once or twice more, the publish will work because the topic will be finally ready and no more crashes will happen.HOW TO TEST:
docker build -t lichtblick-teleop-sim .docker run -it --rm --network host lichtblick-teleop-simOpen Lichtblick with a websocket connection and connect to port 8765
Use teleop panel and confirm the messages are being published on the terminal the image is running
Checklist