Conversation
…nd enums as strings.
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideEnsures incoming protobuf messages are converted to plain JavaScript objects with defaults and with longs/enums represented as strings before being passed to the message handler, avoiding undefined default fields and normalizing numeric/enum representations. Sequence diagram for protobuf message handling and normalizationsequenceDiagram
participant CoreSocket
participant MessageDispatcher
participant TypeResolver
participant ProtobufType
participant Handler
CoreSocket->>MessageDispatcher: on message(msg, msg_info, which_field, ctx, correlation_id)
MessageDispatcher->>MessageDispatcher: set g_ctx_next = ctx
alt msg is not null
MessageDispatcher->>TypeResolver: resolve_type(msg_info, which_field)
alt which_field is set
TypeResolver->>TypeResolver: lookup in g_msg_by_id using which_field
TypeResolver-->>MessageDispatcher: resolved type from g_msg_by_id
else no which_field
TypeResolver-->>MessageDispatcher: resolved type from msg_info.type
end
alt resolve_type exists
MessageDispatcher->>ProtobufType: toObject(msg, defaults true, longs String, enums String)
ProtobufType-->>MessageDispatcher: normalized plain object msg
else no resolve_type
MessageDispatcher-->>MessageDispatcher: msg unchanged
end
else msg is null
MessageDispatcher-->>MessageDispatcher: skip normalization
end
MessageDispatcher->>Handler: f(msg)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
Object.values(g_msg_by_id).find(...)lookup inside the message handler will run on every message and could be expensive ifg_msg_by_idis large; consider precomputing afield_name → typemap or otherwise caching this resolution for the hot path. - Before calling
Object.values(g_msg_by_id), it may be safer to guard againstg_msg_by_idbeingnull/undefinedto avoid runtime errors in edge cases where the global map is not yet initialized.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `Object.values(g_msg_by_id).find(...)` lookup inside the message handler will run on every message and could be expensive if `g_msg_by_id` is large; consider precomputing a `field_name → type` map or otherwise caching this resolution for the hot path.
- Before calling `Object.values(g_msg_by_id)`, it may be safer to guard against `g_msg_by_id` being `null`/`undefined` to avoid runtime errors in edge cases where the global map is not yet initialized.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
nedvedba
approved these changes
Feb 23, 2026
nedvedba
added a commit
that referenced
this pull request
Feb 23, 2026
* fix: prevent defaults being set to undefined, and interpret numbers a… (#1861) * fix: prevent defaults being set to undefined, and interpret numbers and enums as strings. * chore: Auto-format JavaScript files with Prettier * fix: version numbers from proto3 messages follow camel case. (#1868) --------- Co-authored-by: Joshua S Brown <joshbro42867@yahoo.com>
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.
…nd enums as strings.
Ticket
Description
How Has This Been Tested?
Artifacts (if appropriate):
Tasks
Summary by Sourcery
Bug Fixes: