Skip to content

fix: race condition in queue creation, deprecated asyncio API, empty headers - #27

Merged
janbjorge merged 3 commits into
mainfrom
fix/pr24-race-condition-empty-headers
Apr 19, 2026
Merged

janbjorge merged 3 commits into
mainfrom
fix/pr24-race-condition-empty-headers

Conversation

@janbjorge

@janbjorge janbjorge commented Apr 19, 2026 •

Copy link
Copy Markdown
Owner
  • Use if-not-in + local var instead of dict re-lookup in send() — prevents send() from draining a replacement queue if buffers[connection_id] is swapped while a WS connection is active
  • Replace asyncio.get_event_loop() with get_running_loop() (best practice)
  • Fix headers="" → "{}" in client error path so any consumer can parse it with orjson.loads() without a falsy guard
  • Add asyncio_default_fixture_loop_scope to pytest config
  • Add tests proving each fix: queue stability, headers JSON validity, server-side empty headers handling

Closes #24

…headers

- Use if-not-in + local var instead of dict re-lookup in send() — prevents
  send() from draining a replacement queue if buffers[connection_id] is
  swapped while a WS connection is active
- Replace asyncio.get_event_loop() with get_running_loop() (best practice)
- Fix headers="" → "{}" in client error path so any consumer can parse it
  with orjson.loads() without a falsy guard
- Add asyncio_default_fixture_loop_scope to pytest config
- Add tests proving each fix: queue stability, headers JSON validity,
  server-side empty headers handling

Co-authored-by: axel <axelwt@163.com>
@janbjorge
janbjorge force-pushed the fix/pr24-race-condition-empty-headers branch from 1962c1b to 3ac2ded Compare April 19, 2026 18:00
@janbjorge
janbjorge merged commit 2255e09 into main Apr 19, 2026
4 checks passed
@janbjorge
janbjorge deleted the fix/pr24-race-condition-empty-headers branch April 19, 2026 18:06
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