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 #34: don't JSON.parse delete events' IDs #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fasiha
Copy link

@fasiha fasiha commented Sep 1, 2023

Per discussion in #34, we shouldn't JSON.parse delete events' payload because it's a stringy ID and needs to remain a string to avoid exceeding float precision issues.

This appears to be the only event for which this is the case, per Mastodon docs (no other events mention string ID). Therefore, this PR proposes a simple solution: skip JSON.parseing the event payload if it's a delete.

With this in place, the following streaming data chunk:

event: delete\ndata: 110988741790818968\n\n

is parsed into { event: 'delete', data: '110988741790818968' } as expected (and not parseInt('110988741790818968') which is 110988741790818980…). All other events are processed as before.

fasiha added a commit to fasiha/please-caption-mastodon-backup that referenced this pull request Sep 2, 2023
fasiha added a commit to zoetrope69/please-caption-mastodon that referenced this pull request Sep 2, 2023
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.

1 participant