Skip to content

Conversation

@adamziel
Copy link
Collaborator

@adamziel adamziel commented Nov 18, 2025

Replaces recursion with a loop in the filesystem journal code to avoid
the following error when installing Woo on an OPFS site:

Uncaught (in promise) RangeError: Maximum call stack size exceeded
    at normalizeFilesystemOperations (fs-journal.ts:364:17)
    at normalizeFilesystemOperations (fs-journal.ts:473:11)
    ...

Implementation

normalizeFilesystemOperations() used to call itself in a way that
significantly inflated the callstack when either there was either a
lot of operations to normalize, or the normalized operations referenced
each other recursively.

This PR replaces the recursive call with a while(true) loop which
limits the callstack size and allows the normalization to finish.

Testing instructions

Create a new site, save it "to this browser", go to wp-admin, loop up
Woo, click install, confirm it worked.## Motivation for the change, related issues

cc @draganescu

Replaces recursion with a loop in the filesystem journal code to avoid
the following error when installing Woo on an OPFS site:

```
Uncaught (in promise) RangeError: Maximum call stack size exceeded
    at normalizeFilesystemOperations (fs-journal.ts:364:17)
    at normalizeFilesystemOperations (fs-journal.ts:473:11)
    ...
```

\## Implementation

`normalizeFilesystemOperations()` used to call itself in a way that
significantly inflated the callstack when either there was either a
lot of operations to normalize, or the normalized operations referenced
each other recursively.

This PR replaces the recursive call with a while(true) loop which
limits the callstack size and allows the normalization to finish.

\## Testing instructions

Create a new site, save it "to this browser", go to wp-admin, loop up
Woo, click install, confirm it worked.
Removed the test for installing WooCommerce via wp-admin after saving the site.
@adamziel adamziel merged commit 32aa2ff into trunk Nov 18, 2025
30 checks passed
@adamziel adamziel deleted the fix-filesystem-max-call-stack branch November 18, 2025 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants