segmentio / analytics-react-native

The hassle-free way to add analytics to your React-Native app.
https://segment.com/docs/sources/mobile/react-native/
MIT License
354 stars 182 forks source link

FlushInterval Infinity generates a crash #832

Closed arthurgeron-work closed 1 year ago

arthurgeron-work commented 1 year ago

Steps to reproduce

Expected behavior

Actual behavior image

ary31415 commented 1 year ago

Javascript has an Infinity, but Swift/Objective C does not. When your React code is compiled into native code, it can no longer deal with the infinity, so it crashes – as your error message says, not usable as a native method argument. I think you can reproduce this even more easily by simply trying to console.log() an Infinity, or an object containing Infinity.

oscb commented 1 year ago

@arthurgeron-work what @ary31415 mentioned is very likely the case.

I might suggest instead setting it to 0 to prevent any flushes. I believe we ignore any number below 0 when setting flush policies

arthurgeron-work commented 1 year ago

@oscb It may be a good idea to add that to the docs. Thank you.