Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sentry error - IndexSizeError: The index is not in the allowed range

I am getting this error from Sentry repetitively in ios - safari 14.0 in react project.

There is no code trace and no other information than this but it repeats in almost every URL.

I have already searched for the options everywhere. I have tried debugging but I can't replicate it, and so I can't resolve it.

Does anyone know what does this error means? Or how can I add debug information in Sentry?

I have been looking for the solution for a while and couldn't get it. I know it's a bit lack of information to provide but that's why I am asking this. if someone can tell me how to deal with sentry errors if you don't know why it is repeating so often, it will be really helpful.

like image 717
Khushbu Patel Avatar asked Jan 22 '21 03:01

Khushbu Patel


1 Answers

A similar issue still exists. Faced this in Safari when Draft.js is updating the editor state. The error which I see: IndexSizeError: The index is not in the allowed range.

For me, playing around with Paragraph Directioncontext menus items after right-clicking on the Editor selection reproduced the error.

My Solution/hack: Add it to any JS file executing before the Editor file.

const nativeSelectionExtend = Selection.prototype.extend;

  Selection.prototype.extend = function (...args) {
    try {
      return nativeSelectionExtend.apply(this, args);
    } catch (error) {
      console.log('Selection error.', error);
    }
  };

It works properly for me. Maybe will be useful for somebody as well.

Thanks to https://github.com/shpakkdv

like image 53
Prashant Sharma Avatar answered Sep 21 '22 19:09

Prashant Sharma