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

Desktop: Handles #7634: Handling errors when searched term is too long #7764

Merged
merged 1 commit into from
Feb 14, 2023
Merged

Desktop: Handles #7634: Handling errors when searched term is too long #7764

merged 1 commit into from
Feb 14, 2023

Conversation

pedr
Copy link
Collaborator

@pedr pedr commented Feb 13, 2023

Related to #7634

I created a branch wrapping every error occurrence of the error "Regular expression too large" that seems to happen when a very large text is used as search input.

In the issue discussion, I highlight that I found references about the error in the chrome/v8 bug tracker, but, as far as I know, they should be resolved in the version of Electon we are using (maybe it is just a related bug).
#7634 (comment)

Also, I open the PR to discuss the best way to handle the error in cases like this. From what I understand that are different ways of logging in the application, and I wasn't sure which was the best approach for this case, so I went with the simplest which is just using console.error.

Testing:

Using the input from this file (I was just copying the three lines and using them as a single input):

Behavior before this PR:

If the users do not try to create a New to-do or a New note with the searched term still active in the status bar the bug does not appear to occur.

In the image, the search term is still in the search bar, if I try to create a new to-do or a new note from the File menu or from the buttons beside the search input the application will crash
image

  • With any text editor active
  • Use the provided input as a search term
  • Click anywhere on the screen to make the New to-do and New note buttons available or use the File menu options
  • Try to create a new note or a new to-do
  • The application crashes

Behavior after this PR:

  • With any text editor active
  • Use the provided input as a search term
  • Click anywhere on the screen to make the New to-do and New note buttons available or use the File menu options
  • Try to create a new note or a new to-do
  • The application should still be usable, but a momentary freeze still happens

The error message that is generated

SyntaxError: Invalid regular expression: <expression used in the search> 
(?=$|\s|:|;|\.|,|\-|–|—|‒|_|\(|\)|\{|\}|\[|\]|!|'|"|\+|=)/: Regular expression too large

@laurent22
Copy link
Owner

Another approach would be trim the input so that it doesn't crash the app. But I guess, just not crashing is good enough a fix since we don't need to support massive search strings.

Thanks for looking into it, I confirm indeed that the app no longer crashes and displays this error message in the console

@laurent22 laurent22 merged commit 7d7b7ed into laurent22:dev Feb 14, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Feb 14, 2023
@pedr pedr deleted the handle-long-text-search-bar branch March 10, 2023 14:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants