foxglove / ws-protocol

Foxglove WebSocket protocol specification and libraries
MIT License
99 stars 60 forks source link

call action handlers after action, in c++ server #850

Closed paulsohn closed 1 month ago

paulsohn commented 1 month ago

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, 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.

https://linear.app/foxglove/issue/FG-9181/c-foxglove-websocket-server-ambiguous-handler-invoke-timing

jtbandes commented 1 month ago

Thanks!