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

chore(rc): Remove Remote Config dependency on Long JS #2614

Merged
merged 6 commits into from
Jul 16, 2024

Conversation

erikeldridge
Copy link
Contributor

@erikeldridge erikeldridge commented Jun 26, 2024

Discussion

The conditional logic used by the Remote Config config fetch endpoint hashes randomization IDs into 64 bit numbers (via an algorithm called Farmhash). JS numbers are limited to 53 bits, so we used the long.js package to emulate the fetch endpoint logic in the Admin SDK.

#2603 migrated the Admin SDK to use a Farmhash library that produces BigInt, which supports 64 bit numbers natively, so we can remove the long.js dependency. Additionally, the SDK currently converts the BigInt to a string before converting the string to a longjs object, which is clunky. Long JS also broke the SDK's ES6 compatibility.

Testing

Farmhash produces an unsigned 64 bit number, which we convert to a signed number. Longjs does this by default. For BigInt, we need to do this explicitly via BigInt.asIntN(64, unsignedNumber). I've extracted the hashing logic to a method we can test explicitly.

API Changes

None

@erikeldridge erikeldridge self-assigned this Jun 26, 2024
@lahirumaramba lahirumaramba self-assigned this Jul 2, 2024
Copy link
Member

@lahirumaramba lahirumaramba left a comment

Choose a reason for hiding this comment

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

Thank you! LGTM!

@erikeldridge erikeldridge merged commit 3604443 into master Jul 16, 2024
10 checks passed
@erikeldridge erikeldridge deleted the rc-remove-longjs branch July 16, 2024 21:13
@lahirumaramba lahirumaramba mentioned this pull request Jul 17, 2024
@lahirumaramba lahirumaramba changed the title Remove Remote Config dependency on Long JS chore(rc): Remove Remote Config dependency on Long JS Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants