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

[PM-14206] State value race condition when subscribing for first time #12211

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mzieniukbw
Copy link
Contributor

@mzieniukbw mzieniukbw commented Dec 2, 2024

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-14206

📔 Objective

When subscribing to the observable, where there have been an update to the state, the current state value and updates values race together due to merge operator. The behaviour on which one resolves first is random.

Changed the operator to concat to always get sequential observables. Since updates observable holds the newest value, changed this operator to be first, which current value from store as fallback.

Unit Tests coverage yet to be improved.

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

When subscribing to the observable, where there have been an update to the state, the current state value and updates values race together due to `merge` operator. The behaviour on which one resolves first is random. Changed the operator to concat to always get sequential observables. Since updates observable holds the newest value, changed this operator to be first, which current value as fallback in case there is no value.
@mzieniukbw mzieniukbw requested a review from a team as a code owner December 2, 2024 15:15
@mzieniukbw mzieniukbw requested a review from a team December 2, 2024 15:22
Copy link
Contributor

github-actions bot commented Dec 2, 2024

Logo
Checkmarx One – Scan Summary & Detailsa052de1b-0d57-4534-87a7-142f7ec43d86

New Issues

Severity Issue Source File / Package Checkmarx Insight
LOW Client_JQuery_Deprecated_Symbols /apps/cli/src/service-container/service-container.ts: 876 Attack Vector

@mzieniukbw mzieniukbw marked this pull request as draft December 2, 2024 15:41
@mzieniukbw
Copy link
Contributor Author

Converting to draft since tests seems to be failing. Need to investigate.

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