Skip to content

fix(watch,wait): register update handlers before connecting - #289

Open
ApexAiOfficial wants to merge 1 commit into
gotd:mainfrom
ApexAiOfficial:up/register-handlers-first
Open

ApexAiOfficial wants to merge 1 commit into
gotd:mainfrom
ApexAiOfficial:up/register-handlers-first

Conversation

@ApexAiOfficial

Copy link
Copy Markdown

watch and wait added their handlers to the update dispatcher inside the run
callback, i.e. after the client had connected and could already be
dispatching updates. tg.UpdateDispatcher keeps handlers in a plain map, so
registering concurrently with dispatch is a data race (and can panic with a
concurrent map write).

runParams gains a register hook that connectWith calls on the fresh
dispatcher before the client is created. The message stream is registered
there and stays inert until armed with the resolved peer filter, which keeps
the existing behavior: events before the filter is known were never delivered.

🤖 Generated with Claude Code

watch and wait added their handlers to the update dispatcher inside the run
callback, i.e. after the client had connected and could already be
dispatching updates. tg.UpdateDispatcher keeps handlers in a plain map, so
registering concurrently with dispatch is a data race (and can panic with a
concurrent map write).

runParams gains a register hook that connectWith calls on the fresh
dispatcher before the client is created. The message stream is registered
there and stays inert until armed with the resolved peer filter, which keeps
the existing behavior: events before the filter is known were never delivered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant