jsonapi-serializer icon indicating copy to clipboard operation
jsonapi-serializer copied to clipboard

fix(deserialization): deserialization with very big ids is very slow

Open alex00 opened this issue 6 years ago • 4 comments

In the function findIncluded in jsonapi-serializer/lib/deserializer-utils.js

var path = [
  from.type,
  from.id,
  relationshipName,
  relationshipData.type,
  relationshipData.id,
]

_merge(alreadyIncluded, _set({}, path, true));

_merge(alreadyIncluded, _set({}, path, true)) will be an array of from.id elements.

For exemple if from.id value is '20000000', alreadyIncluded will be an array of 20000000 elements.

alex00 avatar Dec 05 '18 12:12 alex00

This just bit us today - hope this can get merged soon.

dabernathy89 avatar Feb 25 '19 23:02 dabernathy89

Ran into this issue as well.

Edit: I confused myself. This PR as-is fixes the problem for me. Can make a separate PR if I see this one stagnate -- hope we can get this merged in soon.~~ Thank you @SeyZ / @alex00 / @jboler / @itsfadnis !

~~Seems like this PR is not enough as-is -- the changes suggested by @jboler and implemented by @itsfadnis at 4d5d9b664208c86d571ff6165940f2215ad8c32b have solved the problem for me.~~

~~Since @itsfadnis' fork has a few other changes on master, I made a minimal fork here: https://github.com/runtrizapps/jsonapi-serializer~~

~~This change can be opted into with the following in package.json:~~ -snip-

davidgovea avatar Aug 22 '19 00:08 davidgovea

Same problem here. I use ids like 25241661 and this ends up with a "JavaScript heap out of memory" error. After manually applying the fix of jboler the problem was solved.

MikeScheurwater avatar Aug 23 '19 06:08 MikeScheurwater

@alex00 Could you check the comments in your PR, update it and rebase?

saulotoledo avatar Jun 01 '20 22:06 saulotoledo