Skip to content

Fix data loss when switching notes with unsaved edits#1097

Open
cirosec-ffr wants to merge 1 commit into
dfir-iris:developfrom
cirosec-ffr:develop
Open

Fix data loss when switching notes with unsaved edits#1097
cirosec-ffr wants to merge 1 commit into
dfir-iris:developfrom
cirosec-ffr:develop

Conversation

@cirosec-ffr

Copy link
Copy Markdown

Hi,

while using IRIS we identified a bug, which consistently deleted our notes.

Bug Description

Unsaved edits to a note were silently lost when switching to another note before the 10s autosave timer fired. The pending timer was orphaned and later saved the new note's content back to itself, while the old note's in-memory edits were destroyed with the editor.

Bug Reproduction

  1. Write content into note A
  2. Without pressing CTRL+S or waiting for the autosave switch to note B
  3. Note B is loaded discarding all unsaved changes from note A without any visible indication for the user.

Fix

Flush unsaved edits (fire-and-forget) before destroying the editor on note switch, plus hardening:

  • Cancel pending autosave timer before switching
  • Guard async save callbacks against stale UI updates (skip if no longer on that note)
  • Unbind keyup handlers before rebinding to prevent stacking across switches
  • Add re-entrancy guard against out-of-order AJAX responses
  • Bind autosave timer to a captured note ID (defense in depth)
  • Gate saves on a note_dirty flag to avoid spurious POSTs on clean switches

Cheers!

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • api_*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7f438e93-9b50-4c49-bc21-0cab696f87cd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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