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

fix an obnoxious uglify issue #2039

Merged
merged 4 commits into from
Aug 1, 2019
Merged

fix an obnoxious uglify issue #2039

merged 4 commits into from
Aug 1, 2019

Conversation

Feiyang1
Copy link
Member

@Feiyang1 Feiyang1 commented Jul 31, 2019

@ryanpbrewster reported an issue where uglify-js uglify this function incorrectly. As a result, the uglified code does wrong thing on multi-byte utf8 characters.
This function is being used in RTDB, so some user data in RTDB might have been corrupted.

As an illustration

arr[idx++] = 0;
arr[idx++] = 1;

is turned into:

arr[idx++] = (arr[idx++] = 1, 0)

The issue doesn't exist in the latest uglify-js anymore, so we upgrade uglify-js to 3.6.0

Fixes: #2035

Copy link
Contributor

@ryanpbrewster ryanpbrewster left a comment

Choose a reason for hiding this comment

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

I can't think of any way to prevent regressions here. Can we maybe add this to a package.json somewhere?

@schmidt-sebastian
Copy link
Contributor

I can't think of any way to prevent regressions here. Can we maybe add this to a package.json somewhere?

Isn't this a regression in UglifyJS? They could break us again with a 3.6.1 release if they don't have tests for this.

@schmidt-sebastian
Copy link
Contributor

@Feiyang1 Can you add a Changelog entry for the RTDB component?

@Feiyang1
Copy link
Member Author

Okay. I added uglify-js@3.6.0 as a direct dependency in Firebase and excluded it from auto dep update, so we should always get 3.6.0 going forward.

@mikelehen
Copy link
Contributor

Is the plan to pin indefinitely? That seems non-ideal. Presumably uglify will make improvements in the future that improve bundle size, etc. and we won't get them. 😢

Sebastian thinks this is the fix on their end: https://github.com/mishoo/UglifyJS2/pull/3430/files and they added a regression test.

It would not be unreasonable for us to also add a regression test, assuming it's not too convoluted to trigger the bug... So we could do that too.

Not psyched about pinning forever. :)

@Feiyang1
Copy link
Member Author

Feiyang1 commented Jul 31, 2019

@schmidt-sebastian @ryanpbrewster uglify-js did add a test for this use case - mishoo/UglifyJS@008c236
but I still think it's a good idea to fix uglify-js version as there is no way for us to verify our minified bundles.

@mikelehen
Copy link
Contributor

mikelehen commented Jul 31, 2019

FWIW- Firestore has (had?) the ability to run (most of) our integration tests against minified builds here: https://github.com/firebase/firebase-js-sdk/tree/master/integration/firestore But unfortunately that somehow got disabled and so they've rotted now.

Ideally we'd invest in testing our minified builds at some point. There are lots of ways to break the minified build through our own code changes in addition to UglifyJS changing out from under us. And I suspect us breaking ourselves would be more common (it's happened several times, whereas this is the first/only time UglifyJS has broken us).

So I still think pinning is an over-reaction. UglifyJS has been very stable in the past and they (seem to) do a good job of adding regression tests.

@ryanpbrewster
Copy link
Contributor

My main goal for this PR is to ensure that we don't fall back behind v3.4.10 (which fixed this particular issue). IMO it is safer for us to do this directly in package.json than in yarn.lock.

Agreed that we should run integration tests against the minified builds.

No particular opinion on pinning. It does seem like the number of bugs in uglify-js is going down rather than up, and I appreciate that each fix has a regression test accompanying it. I think there's not a ton of danger in ratcheting forward.

@Feiyang1
Copy link
Member Author

Feiyang1 commented Aug 1, 2019

Decision: Do not pin uglify-js version as it is fairly stable and added test to prevent regression, so we are not too concerned about it breaking us again and we want to get minification improvements with new versions.

Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

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

Sorry, on second look... why are we only modifying yarn.lock and not a package.json file? Doesn't that put us at risk of reverting this in the future?

Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

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

Nevermind. I guess this change is compatible with our current package.json and wouldn't revert (unless rollup-plugin-uglify explicitly reverts)... So I think this is okay.

But it does seem like we have a problem in that our transitive dependencies don't auto-update because we don't auto-recreate our yarn.lock. :-/

@puf
Copy link

puf commented Aug 1, 2019

Is this issue just the root cause for #2035?

@schmidt-sebastian
Copy link
Contributor

schmidt-sebastian commented Aug 1, 2019

Is this issue just the root cause for #2035?

Yes (and for many other customer reports).

@Feiyang1 Feiyang1 merged commit 2b62667 into master Aug 1, 2019
@Feiyang1 Feiyang1 deleted the fei-uglify branch August 1, 2019 18:41
@firebase firebase locked and limited conversation to collaborators Oct 9, 2019
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.

Encoding Issue with long polling
6 participants