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

Use the entire hash when generating unique id #1905

Merged
merged 2 commits into from
May 19, 2021
Merged

Conversation

atesgoral
Copy link
Contributor

@atesgoral atesgoral commented May 19, 2021

Description

Fixing two issues:

  1. The generateID() function used by the Babel plugin is grabbing the first 5 characters of the stringified hash for no reason. The string-hash library returns 32-bit unsigned numbers and the maximum length a stringified hash can get is just 7 ((0xffffffff).toString(36).length) -- so there's really no point in trimming it to 5 characters. Trimming increases the chance of collision by 1296-fold (parseInt('100', 36)).
  2. The test setup is wrong. Number.MAX_SAFE_INTEGER is 0x1fffffffffffff -- waaay over 0xffffffff :)

Type of change

  • react-i18n Patch: Bug (non-breaking change which fixes an issue)
  • Minor: New feature (non-breaking change which adds functionality)
  • Major: Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have added a changelog entry, prefixed by the type of change noted above (Documentation fix and Test update does not need a changelog as we do not publish new version)

@atesgoral atesgoral requested a review from a team May 19, 2021 16:57
@atesgoral atesgoral added the Type: Bug 🐛 Something isn't working label May 19, 2021
@atesgoral atesgoral merged commit 0bf14fe into main May 19, 2021
@atesgoral atesgoral deleted the babel-plugin-hash-tweak branch May 19, 2021 17:29
@shopify-shipit shopify-shipit bot temporarily deployed to production May 20, 2021 19:32 Inactive
@shopify-shipit shopify-shipit bot deployed to production-core-js-3-entry May 26, 2021 15:07 Active
@shopify-shipit shopify-shipit bot temporarily deployed to gem June 23, 2021 20:18 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants