You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reason:
Readonly function sets new property on object recursively. This may cause this error when meeting frozen variables. Of course this error can also happen when using readonly directly on frozen objects.
[Vue warn]: Error in setup: "TypeError: Cannot define property __v_rawToReadonly, object is not extensible"
TypeError: Cannot define property __v_rawToReadonly, object is not extensible
solvement: #12798
This fix can simply solve the issue by checking the extensibility of target, and keep the temp proxy at the same time, but leaving existing proxy cache useless.
The main reason is the "isReadonly" judgement, but it's difficult to change this basic feature, and the frozen target may still contain not frozen things? As this case may happen rarely, this fix is enough now and willing for future improvements.
The text was updated successfully, but these errors were encountered:
My team have an inner lib using class & static for enums. When we upgrade fron 2.6 to 2.7, and delete composition api, this bug comes out. I finally find out that we use the Object.freeze in the enums lib, and this causes error with another lib, which is using readonly on it.
Version
2.7.10
Reproduction link
codesandbox.io
Steps to reproduce
reason:
Readonly function sets new property on object recursively. This may cause this error when meeting frozen variables. Of course this error can also happen when using readonly directly on frozen objects.
code:
import { readonly } from 'vue';
const test = {
variable: { tp: 1 },
}
Object.freeze(test.variable);
const readonlyTest = readonly(test);
export default {
name: "App",
setup() {
const { variable } = readonlyTest;
return {
variable,
}
},
};
What is expected?
go well
What is actually happening?
[Vue warn]: Error in setup: "TypeError: Cannot define property __v_rawToReadonly, object is not extensible"
TypeError: Cannot define property __v_rawToReadonly, object is not extensible
solvement:
#12798
This fix can simply solve the issue by checking the extensibility of target, and keep the temp proxy at the same time, but leaving existing proxy cache useless.
The main reason is the "isReadonly" judgement, but it's difficult to change this basic feature, and the frozen target may still contain not frozen things? As this case may happen rarely, this fix is enough now and willing for future improvements.
The text was updated successfully, but these errors were encountered: