composition-api icon indicating copy to clipboard operation
composition-api copied to clipboard

fix: ssrRef crashes with nested frozen object

Open pleinon opened this issue 3 years ago â€ĸ 1 comments

🐛 The bug I am using Apollo Client which returns response data as frozen (Object.freeze()) on development mode. Looks like this causes ssrRef.value mutation to crash when frozen data has nested objects:

'get' on proxy: property 'nested' is a read-only and non-configurable data property on the proxy target but the proxy did not return its actual value (expected '#<Object>' but got '[object Object]')

đŸ› ī¸ To reproduce Steps to reproduce the behavior:

const crashTest = ssrRef<any | null>(null)
crashTest.value = Object.freeze({
  test: 'works',
  nested: {}, // crash
})

🌈 Expected behaviour ssrRef should be able to handle frozen complex objects.

â„šī¸ Additional context Sample is greatly simplified from my Pinia-state. Crashing code is executed in store during server side useFetch.

pleinon avatar Jan 18 '22 08:01 pleinon

We're experiencing the same issue and the only workaround we found was to deep-clone all results coming from ApolloClient which is pretty bad for performance. Would be great to have a proper fix 🙏

pmrotule avatar May 05 '22 15:05 pmrotule