I was debugging why I was being notified of deleted statuses whose IDs I didn't recognize. For example, I received the following payload from the mastodon-api message listener:
{ event: 'delete', data: 110988663231921360 }
Note that this is a number (even though Mastodon streaming API docs claim it should be a string ID). However, if in parser.js I console.log the raw message, here's what it receives:
event: delete\ndata: 110988663231921363\n\n
110988663231921363 (≈2**56.623) is bigger than MAX_SAFE_INTEGER so it gets rounded to the value coming out of the message listener:
Do you have any tips on how the parser should be modified to handle this special case? Should we have a list of events that need to be treated as strings (like delete) and pass that through as-is without any JSON decoding?
I was debugging why I was being notified of deleted statuses whose IDs I didn't recognize. For example, I received the following payload from the mastodon-api
message
listener:Note that this is a number (even though Mastodon streaming API docs claim it should be a string ID). However, if in
parser.js
I console.log the raw message, here's what it receives:110988663231921363 (≈
2**56.623
) is bigger than MAX_SAFE_INTEGER so it gets rounded to the value coming out of themessage
listener:Note how the two numbers above aren't the same.
Do you have any tips on how the parser should be modified to handle this special case? Should we have a list of events that need to be treated as strings (like
delete
) and pass that through as-is without any JSON decoding?