desktop / desktop

Focus on what matters instead of fighting with Git.
https://desktop.github.com
MIT License
19.73k stars 9.42k forks source link

RangeError: Invalid string length (History can't be opened / Github Desktop crashes) #15355

Open Reecstuff opened 2 years ago

Reecstuff commented 2 years ago

The problem

You have long waiting Time upon clicking on History?

You get stuck waiting for History to open?

Your Github Desktop crashes after a few seconds and you see the error RangeError: Invalid String Length as posted in the screenshot down below?


So congratulation you have a commit message in your History that is too long for the UI to load 🎉
This happens because you used Squash and merge too often in your repo. Squash and merge generates a commit message description that includes all of your commits and all commits of other Squash and merge commits. After using this for a while your message gets so long it increases the loading time of your history and in the end crashes GitHub Desktop. You can also reproduce this behavior with every other Git Client, like Git Fork if you click on the bugged commit. Because GitHub Desktop loads your history in the background after startup it crashes after a few seconds upon finding the string the UI can't handle.

How to solve this (until it is fixed)?

That's easy "just" make a new repo and delete the old one. The complete history ist bugged because of this and you can only open the history via git log in a command line tool like Git Bash.

Save your local files and remove all git related files / folders from your project. Delete your old Repo on the server. Create a new Repository and clone it, drag your old files into your new repository, commit, push and done.

How to prevent this from happening?

Currently you should not use Squash and merge and just use normal merge. Or you could amend your commit after Squash and merge before pushing and delete the description.

What would I except of Squash and merge?

Squash and merge should not generate a description which includes all commits. I just need a Title like "Squash and merge otherbranch into currentbranch" instead of the currently misleading message "Squashed commit of the following:". Most of the time you only see the title and the description is one click too far away.

Release version

3.0.8

Operating system

Windows 11

Steps to reproduce the behavior

  1. Setup new Repo
  2. Create two or more branches beside main (I name them here branch1 and branch2
  3. Squash and merge main into branch1
  4. Commit multiple commits into branch1 (the more the better)
  5. Squash and merge branch1 into main
  6. Squash and merge main into branch2
  7. Commit multiple commits into branch2
  8. Squash and merge main into branch2
  9. Squash and merge branch2 into main
  10. Repeat steps 3-9

With this setup you should only have "Squashed commit of the following:" commits in your history, so the commit messages stack up nicely and the description string of your commits gets longer and longer. After some time you will notice that your history loads slower and gets stuck after more commits. If you go even further Github Desktop will show you the expected Error RangeError: Invalid string length.

An important thing to note: All your other Repos are still working in Github Desktop, just switch to them and the history opens as expected.

Log files

No response

Screenshots

Invalid_String_Length_Error

Additional context

As @steveward mentioned in #13006 I should put this into a new Issue and here it is.

suhasabhishek commented 2 years ago

@Reecstuff Can I work on this?

adnan-nazir commented 9 months ago

I'm facing the same issue on MacBook Pro (15-inch, 2019).
Not only the cases written above. Github is unable to merge code properly, even I GitHub desktop application is crashing and throwing the exception(attached screenshot).

Screenshot 2024-01-23 at 3 13 00 PM