node-twitter-api-v2 icon indicating copy to clipboard operation
node-twitter-api-v2 copied to clipboard

[Question] What is the convention around handling TweetParseError errors?

Open jbyman opened this issue 1 year ago • 0 comments

Hello,

Thank you for this library! This has been great so far. I had a question I was hoping you'd be able to help with (apologies if I missed this in the docs or existing issues).

I'm using this library for some reasonably high throughput tweets, and occasionally we'll hit the tweet parse errors:

stream.on(ETwitterStreamEvent.TweetParseError, (err) => {
      Log('Error parsing tweet from stream', {
        msg: err.message,
        name: err.name,
      });
});

This is relatively seldom, only once in every few thousand tweets. However, I'm curious what the intended behavior should be on my side? The errors look something like:

Unexpected non-whitespace character after JSON at position {}

My assumption is that this is due to the partial tweets received from Twitter, where the buffer gets corrupted and the tweet isn't JSON-parsable. I have reconnect logic in the case of errors which seems to work well, but my question is: is this error actionable? As far as I can tell we don't have access to the corrupted JSON itself, but I'm curious what I should be doing when this signal occurs, if anything?

Thank you in advance!

jbyman avatar Jun 13 '24 20:06 jbyman