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 race condition when editing the "Check" field in the note #967

Merged
merged 2 commits into from
Nov 6, 2024

Conversation

H3mul
Copy link
Contributor

@H3mul H3mul commented Nov 2, 2024

Noticed this weird bug:

  • Add a note with a boolean (checkbox) field in the header (eg, closed)
  • Enable the "Checked" field function in Board view (set Checked to our boolean field, closed):

image

  • Open the note in a new tab (Projects tab still loaded)
  • Change the value of the closed field in the note (not in Board view)

Obsidian freezes, as Projects falls into the following race condition:

  1. Note file edit triggers a view update in Svelte
  2. Card Checkbox on:check() is triggered, since the checked state changed (call, source)
  3. handleRecordCheck is triggered, complementing the checked state again (source)
  4. checked state complement causes another file edit trigger again, repeat

Easy fix: only trigger handleRecordCheck() when we click the checkbox in Board view, dont respond to all checked field changes

(note checked field changed -> note file changed -> on:check() triggered -> handleRecordCheck() complements checked state -> on:check() triggered, ...)
@Acylation
Copy link
Collaborator

Thanks! Will review it this weekend.

@Acylation Acylation added kind/bug Something isn't working priority/critical Must be must be worked on before anything else. labels Nov 2, 2024
@Acylation
Copy link
Collaborator

Calendar checkbox has a similar problem. Working on a better fix.

@Acylation Acylation merged commit 1131c57 into marcusolsson:main Nov 6, 2024
1 check passed
@H3mul H3mul deleted the fix-note-check-race-condition-pr branch November 6, 2024 04:44
@Acylation Acylation added this to the next milestone Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working priority/critical Must be must be worked on before anything else.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants