Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: RangeError: Maximum call stack size exceeded. when openning the application #2387

Open
1 of 5 tasks
lelemm opened this issue Feb 22, 2024 · 6 comments
Open
1 of 5 tasks
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@lelemm
Copy link

lelemm commented Feb 22, 2024

Verified issue does not already exist?

  • I have searched and found no existing issue

Is this related to GoCardless, Simplefin or another bank-sync provider?

  • I have checked my server logs and could not see any errors there
  • I will be attaching my server logs to this issue
  • I will be attaching my client-side (browser) logs to this issue
  • I understand that this issue will be automatically closed if insufficient information is provided

What happened?

Imported some OFX with no problems, then I imported an CSV, categorized its transactions. Tried to go to budget, this error starts happening. Now I'm unable to open the application at all.

What error did you receive?

graph-data-structure.ts:79 Uncaught (in promise) RangeError: Maximum call stack size exceeded
at ep (graph-data-structure.ts:79:13)
at ep (graph-data-structure.ts:85:9)
at ep (graph-data-structure.ts:85:9)
at ep (graph-data-structure.ts:85:9)
at ep (graph-data-structure.ts:85:9)
at ep (graph-data-structure.ts:85:9)
at ep (graph-data-structure.ts:85:9)
at ep (graph-data-structure.ts:85:9)
at ep (graph-data-structure.ts:85:9)
at ep (graph-data-structure.ts:85:9)

Where are you hosting Actual?

Docker

What browsers are you seeing the problem on?

Chrome, Microsoft Edge

Operating System

Windows 11

@lelemm lelemm added the bug Something isn't working label Feb 22, 2024
@lelemm
Copy link
Author

lelemm commented Feb 22, 2024

Linking to closed issue due missing information: #2241

@lelemm
Copy link
Author

lelemm commented Feb 22, 2024

@MatissJanis
Copy link
Member

Ok, so it took me quite a while to get to the bottom of this. The crux of the problem is - transactions created WAYYYY in the past cause issues with budget table calculations. The simple fix for you would be - don't import transactions from 1980. Use the last few years.

To proper patch this we need to refactor topological sorting from a recursive implementation to an iterative one.

function topologicalSortUntil(name, visited, sorted) {
visited.add(name);
const iter = adjacent(name).values();
let cur = iter.next();
while (!cur.done) {
if (!visited.has(cur.value)) {
topologicalSortUntil(cur.value, visited, sorted);
}
cur = iter.next();
}
sorted.unshift(name);
}

@MatissJanis MatissJanis added the help wanted Extra attention is needed label Mar 15, 2024
@lelemm
Copy link
Author

lelemm commented Mar 19, 2024

Yeah, I imagined the problem was that.
A suggestion is to set a limit to the past where is "old enough" to actual keeps working.
In other words, if the user sets a date to much in the past, don't save it.

It's better to have this kind of lock cuz I see this as critical bug. The file is exported from the bank that way. If you don't pay enough attention when doing it, you just lose your instance or have to edit the database file by hand.

@lelemm
Copy link
Author

lelemm commented Mar 19, 2024

Out of curiosity, I tried to see how far back we have to go to break the current code:
Considering today 19-03-2024, I had to put 19-03-2028 to have the same error, that's 96 years to the past. So, if you check if the transaction is more than 90 years old, we are safe.

This creates a interesting bug (hardly able to see by us): If I starting using actual today, it will fail to load at 19/03/2120. lol

@lelemm
Copy link
Author

lelemm commented Mar 19, 2024

This would be the workaround I was thinking about.

I didn't try to run this code, I just forked and tried pinpoint where should be the change I suggested.

Since actual has syncing features for offline use, I can imagine there is a better/another place to make the same change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants