redux-requests: Function `denormalize` throws `RangeError: Maximum call stack size exceeded` - support selecting normalized objects by id

I still haven’t been able to figure out how or why, but sometimes the function denormalize in normalizers/denormalize.js, will go into an infinite recursion loop while loading data.

Uncaught RangeError: Maximum call stack size exceeded
    at denormalize.js:21
    at Array.reduce (<anonymous>)
    at denormalize (denormalize.js:21)
    at denormalize (denormalize.js:7)
    at denormalize.js:24
    at Array.reduce (<anonymous>)
    at denormalize (denormalize.js:21)
    at denormalize (denormalize.js:7)
    at denormalize.js:12
    at Array.map (<anonymous>)

Not sure where to start debugging it… The trace starts in getQuerySelector, so I’m trying to use that to obtain the result of a normalized request.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 17 (9 by maintainers)

Most upvoted comments

@zeraien usedKeys would be provided to new selector like getNormalizedObjectById

normally this selector would just get id and it would return proper object, but if leading to recursive error, this would be catched and warning would be shown in console.

then someone could do thing like:

const myObject = getNormalizedObjectById(state, { id: '1', usedKeys: {
  id: true,
  name: true,
  bestFriend: {
    id: true,
    name: true,
  }  
}}});

So usedKeys would be provided in easy to work with way by human, while library would convert it to the same structure as stored in reducer. Probably this would be used very sparingly, only when recursive relationship, but we would have an escape hatch so I could work on getNormalizedObjectById