FormidableLabs / react-fast-compare

fastest deep equal comparison for React
MIT License
1.59k stars 54 forks source link

Error handling failing in localized versions of Internet Explorer #27

Closed excentrik closed 6 years ago

excentrik commented 6 years ago

In https://github.com/FormidableLabs/react-fast-compare/blob/2aafd69a5022ee196b33ae0b06f2ed5bc0a1dfa4/index.js#L75

there's a regex comparison with the error message, but it assumes the language of the error is English. Trying to use the library in IE11, in the event of "out of stack", the error is not captured.

For instance, in a Finnish version of IE11, the message is "Pinotila ei riitä" as seen in the attachment. screen shot 2018-07-02 at 10 28 00

One possible fix is to replace the aforementioned line with

if (
(error.message && error.message.match(/stack|recursion/i)) ||
(error.number == -2146828260)
) {

since IE error number for "out of stack" is language-independent.

chrisbolin commented 6 years ago

merged the fix and will cut a release soon

chrisbolin commented 6 years ago

fixed in react-fast-compare@2.0.2