Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: queue channel WS events until the channel is initialized #1179

Merged
merged 3 commits into from
Oct 3, 2023

Conversation

MartinCupela
Copy link
Contributor

CLA

  • [ X ] Code changes are tested

Description of the changes, What, Why and How?

A channel is flagged as initialized only after channel.query call successfully returns inside channel.watch() method. The WS events for a given channel can however arrive sooner to the client than channel.query call returns. Processing WS events before the channel.query call returns leads to checking whether the channel has been initialized. If the channel was not flagged as initialized, then the code throws error.

To prevent processing WS events before the initialization has finished, this PR introduces a WS event queue for a channel. There will all the event objects be gathered until the channel is flagged as initialized. Once flagged as initialized, the queue is flushed.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 29, 2023

Size Change: +1.41 kB (0%)

Total Size: 320 kB

Filename Size Change
dist/browser.es.js 70.1 kB +317 B (0%)
dist/browser.full-bundle.min.js 37.9 kB +155 B (0%)
dist/browser.js 71.1 kB +308 B (0%)
dist/index.es.js 70.2 kB +317 B (0%)
dist/index.js 71.2 kB +308 B (0%)

compressed-size-action

src/channel.ts Outdated Show resolved Hide resolved
@MartinCupela MartinCupela merged commit 2073579 into master Oct 3, 2023
5 of 6 checks passed
@MartinCupela MartinCupela deleted the fix/queue-ws-events-before-channel-init branch October 3, 2023 14:09
@github-actions github-actions bot mentioned this pull request Oct 3, 2023
rchl added a commit to rchl/stream-chat-js that referenced this pull request Nov 29, 2023
* master: (44 commits)
  chore: release v8.14.4 (GetStream#1203)
  fix: add default contentType as multipart/form-data in sendFile (GetStream#1202)
  chore: release v8.14.3 (GetStream#1200)
  fix: use postForm instead of post for sending files (GetStream#1199)
  chore: release v8.14.2 (GetStream#1197)
  fix: reload channel state if frozen flag changed (GetStream#1196)
  chore(release): v8.14.1 (GetStream#1195)
  Update user reference in channel read data (GetStream#1194)
  chore(release): v8.14.0 (GetStream#1193)
  feat: axios upgrade to v1 (GetStream#1192)
  Revert "fix: queue channel WS events until the channel is initialized" (GetStream#1189)
  chore(release): v8.13.1 (GetStream#1188)
  fix: undefined values in query params (GetStream#1187)
  chore(release): v8.13.0 (GetStream#1186)
  feat: support for SNS (GetStream#1185)
  chore: release v8.12.4 (GetStream#1184)
  fix: evaluate channel.lastRead when channel is not initialized (GetStream#1183)
  chore(release): v8.12.3 (GetStream#1182)
  fix: queue channel WS events until the channel is initialized (GetStream#1179)
  chore: release v8.12.2 (GetStream#1181)
  ...
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.

3 participants