-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: encoding of previously-used values #38
Conversation
I've added what I believe to be a fix. It seemed like the issue was with encoding rather than decoding. The object encoded after the reused value would end up decoding starting at a preceding index, leading to the circular reference, as I saw in my original issue. The fix doesn't feel elegant, but I've given it some testing in my real project and it seems sound. @jacob-ebey hoping can take a closer and wiser look. |
I'm really glad you managed to track this one down - I spent far too long trying to create a minimal reproduction. |
Me too, I really just got lucky with a reproducible example in my project. @nick-potts it would be great to know if this fix resolves your issue too – any extra test time is helpful. Here is the patch I'm using:
|
Yep, gave it a shot and it works an absolute treat. Mine's probably a great stress test on it, lots of very similar data with lots of nested keys with the same name. Also passing about 50-200 promises per page load. |
fd9f3eb
to
eacfb21
Compare
woot woot |
I tried 2.2.2, but its reporting an internal error. Will get back to you when I understand it. |
I had more occurrences of #36 in my project, and I was able to isolate the issue much better. I believe this test is the absolute minimal case.
Reused values certainly work in many other scenarios, but this specific setup results in a circular reference for the third object key:
data
.data
is not an object, no failure occurs'baz'
is not used as object value in 'foo', or if it is an object value inbar
, no failure occurs.In my codebase,
foo
,bar
, anddata
are all independent promises resolved from a Remix loader. Whendata
resolves prior tobar
, no failure occurs. The PREVIOUSLY_RESOLVED value must resolve prior to the data object. In doing so, it seems it taints either thevalues
orhydrated
cache inunflatten