Skip to content

Cannot assign to read only property 'Symbol(Symbol.metadata)' #10

@iar5

Description

@iar5

AgoraRTC SDK version

4.19.0

Fail Rate

100%

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-p9wrtoyz?file=package.json,tsconfig.json,src%2Fmain.ts&terminal=dev

Steps to reproduce

Description

  • Using @colyseus/schema@^3.0.0 together with any module from [email protected] triggers the following error.
  • Even calling a single method—e.g. AgoraRTC.setLogLevel(4);—is enough to reproduce it.
  • Colyseus Schema’s @type decorator writes metadata to Function.prototype[Symbol.metadata].
  • However, Agora’s SDK appears to freeze or override Symbol.metadata, preventing Colyseus from attaching decorator metadata.
  • As a result, when both libraries are imported, Colyseus’s attempt to write to Symbol.metadata fails with a TypeError.

Reproduction

  1. Open the minimal StackBlitz project:
    https://stackblitz.com/edit/vitejs-vite-p9wrtoyz?file=package.json,tsconfig.json,src%2Fmain.ts&terminal=dev
  2. Click “Open Preview in New Tab” (top-right corner of the preview pane).
  3. Open DevTools in that new tab. You will immediately see the error in the console.

Error

index.js:950 Uncaught TypeError: Cannot assign to read only property 'Symbol(Symbol.metadata)' of function 'class MyTestState extends Schema {
  constructor() {
    super(...arguments);
    this.testString = "test";
    …<omitted>…
  }
}'
    at Object.initialize (index.js:950:40)
    at index.js:2954:39
    at __decorateClass (index.ts:7:24)
    at index.ts:8:18

Key Questions

  • Why does Agora’s SDK freeze or override Symbol.metadata?
  • Can that behavior be changed so it does not conflict with other decorator-based libraries like Colyseus Schema?

What is expected?

No crash

What is actually happening?

Crash

System Info

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions