Skip to content

Fix stack overflow in calculateLatestCheckpoint#95

Merged
samholmes merged 1 commit into
masterfrom
sam/call-stack-overflow-fix
Mar 10, 2026
Merged

Fix stack overflow in calculateLatestCheckpoint#95
samholmes merged 1 commit into
masterfrom
sam/call-stack-overflow-fix

Conversation

@samholmes
Copy link
Copy Markdown
Contributor

@samholmes samholmes commented Mar 10, 2026

Replace Math.max(...spread) with reduce to avoid exceeding the call stack when a document's versions array is very large.

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Description

none

Note

Low Risk
Small, localized algorithm change in checkpoint calculation plus a changelog entry; behavior should be equivalent but could affect sum/version math if the reduce logic is incorrect.

Overview
Fixes a potential call-stack overflow in calculateLatestCheckpoint when processing documents with very large versions arrays.

Replaces the Math.max(...spread) computation of previousVersion with an iterative reduce, and adds a CHANGELOG entry documenting the fix.

Written by Cursor Bugbot for commit 0ddd7bc. This will update automatically on new commits. Configure here.


Replace Math.max(...spread) with reduce to avoid exceeding the
call stack when a document's versions array is very large.
@samholmes samholmes merged commit 12c6158 into master Mar 10, 2026
2 checks passed
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