facebook/relay

[Modern] bug when updating json scalar field

jardakotesovec opened this issue · 10 comments

I am using JSON Scalar field.

And getting error:

recycleNodesInto.js:48 Uncaught (in promise) TypeError: Cannot assign to read only property 'finishingGroupIds' of object '#<Object>'
    at recycleNodesInto.js:48

when relay store receives update from the mutation with new json scalar value, which has internally additional item in the array. When I reload the page - store interpret the json value just fine, so its just issue when replacing the old json value with new one.

This whole recycleNodesInto function already seems to be doing some magic for flow, so not sure where is actually the root of the problem. Maybe just some condition to avoid stepping into the json scalar field?

I could work on PR if you give me some hints how you think this should be addressed.

screenshot 2017-08-21 10 57 52

I've noticed this since updating to 1.2.0

I've been running into the same issue with JSON fields when upgrading our app to Relay Modern. First occurred in 1.1.0 and upgraded to 1.2.0 and the issue still exists.

After lots of debugging I found that the reason for the failure appears to be the deepFreeze in development mode. If you set a breakpoint on line 48 and in the console type: Object.isFrozen(nextObject['data']) it will return true

@jardakotesovec PR 2051 solves the issue for me. Not sure if it will be approved but for now it sovles the issue.

For anybody else running into this, I've temporarily published to @boltline/relay-runtime. Until this or another fix get merged I'll keep this in sync with Facebook's relay-runtime releases. Once a fix is permanently in place, I'll deprecate all releases of my fork on NPM.

@jardakotesovec, does this only happen in DEV mode?

@jstejada the issue only happens in DEV as can be seen RelayMarkSweepStore:

if (__DEV__) {
deepFreeze(nextSnapshot);
}

Hi ! I am facing the same issue. Any chance this is being fixed soon ? Or is there a way to fix this in dev mode ?

I think this is fixed on v2.0.0

Yup, fixed in v2.0.0

Closing; if the issue persists please let us know and we’ll reopen the issue