Skip to content

Batch operations backup doesn't properly copy events #9

@thedhanawada

Description

@thedhanawada

Problem

When doing batch operations (like adding multiple events at once), the backup for undo/rollback only keeps references to the same Event objects. If something fails partway through, the rollback doesn't actually restore the old state.

File: core/events/EventStore.js

What happens

  1. You start a batch add of 10 events
  2. Events 1-5 succeed and modify the store
  3. Event 6 fails
  4. Rollback tries to restore, but the "backup" points to the same modified objects
  5. Data is corrupted

How to fix

Create actual copies of events before the batch operation:

batchAdd(events) {
  const backup = new Map();
  for (const [id, event] of this.events) {
    backup.set(id, event.clone()); // Make real copies
  }
  // ... rest of batch logic
}

This way rollback has clean copies to restore from.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions