[PR #4877] [CLOSED] Fix #4856: Prevent call stack overflow on large TOML files #6452

Closed
opened 2026-10-31 01:14:34 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4877
Author: @uyg7x
Created: 10/17/2026
Status: ❌ Closed

Base: main ← Head: fix-toml-issue-4856


📝 Commits (1)

  • 0d0b7f5 fix: prevent call stack overflow on large TOML files by using iterative append

📊 Changes

1 file changed (+12 additions, -0 deletions)

View changed files

📝 src/application/ClientConfigurationDocument.ts (+12 -0)

📄 Description

Fixes #4856
What was breaking:
upsertTomlServerSection was using the spread operator (kept.push(...array)) to dump lines into the array. It works fine for normal configs, but if you throw a massive TOML file at it (like the 140,000-line repro case in the issue), the JS engine hits its hard argument limit and just chokes with a RangeError: Maximum call stack size exceeded.
How I fixed it:
Swapped out the spread operator for a straightforward for...of loop in the three spots where it was blowing up (flushing pending lines, appending disabled lines, and splitting replacements). Added a quick appendLines helper to keep the code clean. It pushes items one by one, completely bypassing the engine's argument limit.
Proof it works:
Ran the 140,000-line repro locally. Instead of crashing, the setup command now finishes cleanly with status: "ready" and exit 0.
I didn't touch the actual TOML parsing logic, so all the existing backup, approval, and rollback behavior is still rock solid.
Files touched:

src/application/ClientConfigurationDocument.ts

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/4877 **Author:** [@uyg7x](https://github.com/uyg7x) **Created:** 10/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-toml-issue-4856` --- ### 📝 Commits (1) - [`0d0b7f5`](https://github.com/morluto/rea/commit/0d0b7f58a52a12d78afc2e7b323e0a875fc44a70) fix: prevent call stack overflow on large TOML files by using iterative append ### 📊 Changes **1 file changed** (+12 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/application/ClientConfigurationDocument.ts` (+12 -0) </details> ### 📄 Description Fixes #4856 What was breaking: upsertTomlServerSection was using the spread operator (kept.push(...array)) to dump lines into the array. It works fine for normal configs, but if you throw a massive TOML file at it (like the 140,000-line repro case in the issue), the JS engine hits its hard argument limit and just chokes with a RangeError: Maximum call stack size exceeded. How I fixed it: Swapped out the spread operator for a straightforward for...of loop in the three spots where it was blowing up (flushing pending lines, appending disabled lines, and splitting replacements). Added a quick appendLines helper to keep the code clean. It pushes items one by one, completely bypassing the engine's argument limit. Proof it works: Ran the 140,000-line repro locally. Instead of crashing, the setup command now finishes cleanly with status: "ready" and exit 0. I didn't touch the actual TOML parsing logic, so all the existing backup, approval, and rollback behavior is still rock solid. Files touched: src/application/ClientConfigurationDocument.ts --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:14:34 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6452
No description provided.