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 FeedDetails.equals to compare buffers correctly #107

Merged
merged 2 commits into from
Nov 11, 2022

Conversation

staltz
Copy link
Member

@staltz staltz commented Nov 11, 2022

Context

I got some weird duplicate branches coming out of branchStream, and it turned out that the '.equals()' function wasn't working here:

if (existingDetails && existingDetails.equals(details)) return

Problem

FeedDetails's equals() is too simplistic, it's comparing two buffers with ===, and it's comparing two objects (keys) with === too.

Solution

Compare buffers with Buffer.equals and compare objects with fast-deep-equal.

1st ❌ 2nd ✔️

@staltz staltz requested a review from arj03 November 11, 2022 13:39
Copy link
Member

@arj03 arj03 left a comment

Choose a reason for hiding this comment

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

Ah yes ;) 👍

@staltz staltz merged commit cc6a81c into master Nov 11, 2022
@staltz staltz deleted the fix-feed-details-equals branch November 11, 2022 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants