Skip to content

Add more diff size limits - #3032

Merged
niik merged 10 commits into
masterfrom
limits-are-good
Oct 23, 2017
Merged

niik merged 10 commits into
masterfrom
limits-are-good

Conversation

@joshaber

@joshaber joshaber commented Oct 12, 2017 •

Copy link
Copy Markdown
Contributor

Fixes #2596

This introduces two more limits:

  1. A diff cannot be over 3MB. This is to catch any generally big diff.
  2. A diff cannot have a line longer than 500,000 characters, e.g., minified files.

Both of those are pretty arbitrary, determined by testing what felt slow on my computer 😬 We can tweak them based on feedback.

I created test files with base64 /dev/urandom | head -c 10000000 > file.txt.

I didn't implement the ability to show the diffs anyways. Given that that experience means the app freezes, I'm not sure we wanna allow that without taking a harder look at diff rendering performance.

@joshaber joshaber added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Oct 12, 2017
@shiftkey
shiftkey self-requested a review October 18, 2017 22:52
@niik niik self-assigned this Oct 23, 2017

@niik niik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Comment thread app/src/lib/git/diff.ts Outdated
if (!isValidBuffer(buffer)) {
return true
}

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@joshaber
joshaber removed the request for review from shiftkey October 23, 2017 13:47
@joshaber

Copy link
Copy Markdown
Contributor Author

🐸

@niik
niik merged commit 600db29 into master Oct 23, 2017
@niik
niik deleted the limits-are-good branch October 23, 2017 14:04
@shiftkey shiftkey mentioned this pull request Oct 24, 2017
@jessetan

Copy link
Copy Markdown
Contributor

@joshaber I'm still encountering slow diffs on some files. The max line length of 500,000 seems pretty high (mine has lines 111,000 chars long and takes 15s to diff and syntax highlight). I would argue that any file that has lines of over a few hundred chars is not handwritten, but probably minified. Perhaps a limit of 1000-10,000 chars per line would be better?

@joshaber

joshaber commented Jan 8, 2018

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback @jessetan! I agree we could cut it down even more. I opened #3740 to track that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants