In C++ server, handlers for below events are called before the internal states are fully updated:
subscribe
unsubscribe
client advertise
client unadvertise
subscribe connection graph
As a consequence, some user behavior does not work as expected, such as calling sendMessage() for messages of the requested topic inside of subscription handler. When subscription handler is called, the internal state does not recognize the requested topic as subscribed, and sendMessage() filters out this unsubscribed topic.
This seems to be a bug rather than a spec, because typescript and python server implementations calls listener/emit event after all internal tables are updated.
Changes
For the above events, switch the order of handler call and internal map updates.
Changelog
Guarantees that action handlers in C++ ws server are called after the action has been applied.
Docs
https://github.com/orgs/foxglove/discussions/1049
Description
Problem
In C++ server, handlers for below events are called before the internal states are fully updated:
As a consequence, some user behavior does not work as expected, such as calling
sendMessage()
for messages of the requested topic inside of subscription handler. When subscription handler is called, the internal state does not recognize the requested topic as subscribed, andsendMessage()
filters out this unsubscribed topic.This seems to be a bug rather than a spec, because typescript and python server implementations calls listener/emit event after all internal tables are updated.
Changes
For the above events, switch the order of handler call and internal map updates.
https://linear.app/foxglove/issue/FG-9181/c-foxglove-websocket-server-ambiguous-handler-invoke-timing