fix(events): don't warn/stacktrace on a valid pre-generated handler id#323
Merged
csoler merged 1 commit intoJul 8, 2026
Conversation
Contributor
|
Very surprising PR: the check was added because it's very easy (due to a design flaw) to not initialize a handle ID and replace an existing one by mistake. Normally generateUniqueHandlerId() should be private so that it is only called by the register method itself. Besides, if you allow to bypass the call to generateUniqueHandlerId(), then mLastHandler will not be consistent with the existing list of Ids anymore. |
519c163 to
bad4758
Compare
registerEventsHandler() documents (rsevents.h) that the caller may pass an hId previously obtained from generateUniqueHandlerId(). The JSON API event-stream wrapper (jsonapi.cpp) does exactly this: it pre-generates the id so its SSE callbacks can capture it to unregister themselves, then passes it to registerEventsHandler(). The implementation treated any non-zero hId as an override, calling print_stacktrace() + "Overriding an existing error handler ID ... very unexpected". So every event-stream registration (every webui/mobile connection, plus each 5s reconnect and each 1MB queue restart) dumped a bogus stack trace to the log, contradicting the API's own contract. Only warn when the hId is actually already present in the handler maps, i.e. a real override. A freshly generated id never is (ids are monotonic), so the false positive is gone while genuine accidental id reuse is still reported. Only jsonapi.cpp pre-generates ids; every other caller passes 0, so behaviour there is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
bad4758 to
01b8ac9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(events): don't warn/stacktrace on a valid pre-generated handler id
registerEventsHandler() documents (rsevents.h) that the caller may pass an hId previously obtained from generateUniqueHandlerId(). The JSON API event-stream wrapper (jsonapi.cpp) does exactly this: it pre-generates the id so its SSE callbacks can capture it to unregister themselves, then passes it to registerEventsHandler().
The implementation treated any non-zero hId as an override, calling print_stacktrace() + "Overriding an existing error handler ID ... very unexpected". So every event-stream registration (every webui/mobile connection, plus each 5s reconnect and each 1MB queue restart) dumped a bogus stack trace to the log, contradicting the API's own contract.
Only warn when the hId is actually already present in the handler maps, i.e. a real override. A freshly generated id never is (ids are monotonic), so the false positive is gone while genuine accidental id reuse is still reported. Only jsonapi.cpp pre-generates ids; every other caller passes 0, so behaviour there is unchanged.