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: improper poll state overwrite #1456

Merged
merged 7 commits into from
Jan 30, 2025

Conversation

isekovanic
Copy link
Contributor

@isekovanic isekovanic commented Jan 29, 2025

CLA

  • I have signed the Stream CLA (required).
  • Code changes are tested

Description of the changes, What, Why and How?

This PR fixes a case of overwriting the poll cache when we should not do that. Essentially, hydrating all messages in messageSet.messages whenever channel.query is invoked does 2 things:

  • Takes in all of the new messages and hydrates the cache with them (they do not exist in the cache yet)
  • Also takes in the old messages, which were used as a basis to paginate on top of and rehydrates the cache with them (they already existed in the cache before)

The problem here is; since we do not update message.poll objects at all, but rather use them as an ID reference towards the cache - these polls are stale (since they're retrieved from the stale state and not as an HTTP response). The state is then overwritten with the stale data until we query all messages again.

The bug is particularly noticeable if we do some state changes to a poll (for example vote on it, add some answers or similar) and then paginate elsewhere within the messages (up or down). We can see that the poll will reset back to the state it had on the initial load.

Changelog

Copy link
Contributor

github-actions bot commented Jan 29, 2025

Size Change: -5 B (0%)

Total Size: 469 kB

Filename Size Change
dist/browser.es.js 102 kB -1 B (0%)
dist/browser.full-bundle.min.js 57.4 kB -2 B (0%)
dist/browser.js 103 kB -1 B (0%)
dist/index.es.js 102 kB -1 B (0%)
ℹ️ View Unchanged
Filename Size
dist/index.js 103 kB

compressed-size-action

@isekovanic
Copy link
Contributor Author

Our queryChannels hydration logic also had the same bug (when paginating channels for example). It's fixed with 299a3af.

Thanks @MartinCupela for pointing it out !

@isekovanic isekovanic merged commit 4384085 into master Jan 30, 2025
5 checks passed
@isekovanic isekovanic deleted the fix/improper-poll-state-overwrite branch January 30, 2025 10:37
@github-actions github-actions bot mentioned this pull request Jan 30, 2025
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.

2 participants