Skip to content
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

[Bug]: Schema crash #164

Open
DivXPro opened this issue Feb 15, 2024 · 1 comment
Open

[Bug]: Schema crash #164

DivXPro opened this issue Feb 15, 2024 · 1 comment

Comments

@DivXPro
Copy link

DivXPro commented Feb 15, 2024

Bug description

When I refresh the client page, sometimes the server throws an error in the schema encode part. It seems to happen when the client reconnects to get the latest state, causing an exception. What could be the reason for this?

I log the error
0|colyseus-app | 2024-02-15T23:38:28: assertInstanceType value undefined
0|colyseus-app | 2024-02-15T23:38:28: assertInstanceType type <ref *1> [class Card extends Schema] {
0|colyseus-app | 2024-02-15T23:38:28: _context: Context {
0|colyseus-app | 2024-02-15T23:38:28: types: {
0|colyseus-app | 2024-02-15T23:38:28: '0': [Circular *1],
0|colyseus-app | 2024-02-15T23:38:28: '1': [Function],
0|colyseus-app | 2024-02-15T23:38:28: '2': [Function],
0|colyseus-app | 2024-02-15T23:38:28: '3': [Function],
0|colyseus-app | 2024-02-15T23:38:28: '4': [Function]
0|colyseus-app | 2024-02-15T23:38:28: },
0|colyseus-app | 2024-02-15T23:38:28: schemas: Map(5) {
0|colyseus-app | 2024-02-15T23:38:28: [Circular *1] => 0,
0|colyseus-app | 2024-02-15T23:38:28: [Function] => 1,
0|colyseus-app | 2024-02-15T23:38:28: [Function] => 2,
0|colyseus-app | 2024-02-15T23:38:28: [Function] => 3,
0|colyseus-app | 2024-02-15T23:38:28: [Function] => 4
0|colyseus-app | 2024-02-15T23:38:28: },
0|colyseus-app | 2024-02-15T23:38:28: useFilters: false
0|colyseus-app | 2024-02-15T23:38:28: },
0|colyseus-app | 2024-02-15T23:38:28: _definition: SchemaDefinition {
0|colyseus-app | 2024-02-15T23:38:28: indexes: { id: 0, field: 1, publicSuit: 2, publicRank: 3 },
0|colyseus-app | 2024-02-15T23:38:28: fieldsByIndex: { '0': 'id', '1': 'field', '2': 'publicSuit', '3': 'publicRank' },
0|colyseus-app | 2024-02-15T23:38:28: deprecated: {},
0|colyseus-app | 2024-02-15T23:38:28: descriptors: {
0|colyseus-app | 2024-02-15T23:38:28: _id: [Object],
0|colyseus-app | 2024-02-15T23:38:28: id: [Object],
0|colyseus-app | 2024-02-15T23:38:28: _field: [Object],
0|colyseus-app | 2024-02-15T23:38:28: field: [Object],
0|colyseus-app | 2024-02-15T23:38:28: _publicSuit: [Object],
0|colyseus-app | 2024-02-15T23:38:28: publicSuit: [Object],
0|colyseus-app | 2024-02-15T23:38:28: _publicRank: [Object],
0|colyseus-app | 2024-02-15T23:38:28: publicRank: [Object]
0|colyseus-app | 2024-02-15T23:38:28: },
0|colyseus-app | 2024-02-15T23:38:28: schema: {
0|colyseus-app | 2024-02-15T23:38:28: id: 'string',
0|colyseus-app | 2024-02-15T23:38:28: field: 'string',
0|colyseus-app | 2024-02-15T23:38:28: publicSuit: 'string',
0|colyseus-app | 2024-02-15T23:38:28: publicRank: 'string'
0|colyseus-app | 2024-02-15T23:38:28: }
0|colyseus-app | 2024-02-15T23:38:28: },
0|colyseus-app | 2024-02-15T23:38:28: _typeid: 0
0|colyseus-app | 2024-02-15T23:38:28: }
0|colyseus-app | 2024-02-15T23:38:28: assertInstanceType klass <ref *1> ArraySchema {
0|colyseus-app | 2024-02-15T23:38:28: '$changes': ChangeTree {
0|colyseus-app | 2024-02-15T23:38:28: changed: false,
0|colyseus-app | 2024-02-15T23:38:28: changes: Map(0) {},
0|colyseus-app | 2024-02-15T23:38:28: allChanges: Set(5) { 3, 2, 1, 4, 0 },
0|colyseus-app | 2024-02-15T23:38:28: caches: {},
0|colyseus-app | 2024-02-15T23:38:28: currentCustomOperation: 0,
0|colyseus-app | 2024-02-15T23:38:28: ref: [Circular *1],
0|colyseus-app | 2024-02-15T23:38:28: indexes: {},
0|colyseus-app | 2024-02-15T23:38:28: parent: TexasRoomState {
0|colyseus-app | 2024-02-15T23:38:28: name: [Getter/Setter],
0|colyseus-app | 2024-02-15T23:38:28: players: [Getter/Setter],
0|colyseus-app | 2024-02-15T23:38:28: currentGameState: [Getter/Setter],
0|colyseus-app | 2024-02-15T23:38:28: currentGameTurnStage: [Getter/Setter],
0|colyseus-app | 2024-02-15T23:38:28: nextGameTurnStage: [Getter/Setter],
0|colyseus-app | 2024-02-15T23:38:28: table: [Getter/Setter],
0|colyseus-app | 2024-02-15T23:38:28: maxPlayers: [Getter/Setter],
0|colyseus-app | 2024-02-15T23:38:28: minPlayers: [Getter/Setter],
0|colyseus-app | 2024-02-15T23:38:28: symbol: [Getter/Setter],
0|colyseus-app | 2024-02-15T23:38:28: currentSeat: [Getter/Setter],
0|colyseus-app | 2024-02-15T23:38:28: lastRiseSeat: [Getter/Setter],
0|colyseus-app | 2024-02-15T23:38:28: pots: [Getter/Setter],
0|colyseus-app | 2024-02-15T23:38:28: smallBlind: [Getter/Setter],
0|colyseus-app | 2024-02-15T23:38:28: bigBlind: [Getter/Setter],
0|colyseus-app | 2024-02-15T23:38:28: minBuyIn: [Getter/Setter],
0|colyseus-app | 2024-02-15T23:38:28: maxBuyIn: [Getter/Setter],
0|colyseus-app | 2024-02-15T23:38:28: currentBet: [Getter/Setter],
0|colyseus-app | 2024-02-15T23:38:28: betUnit: [Getter/Setter]
0|colyseus-app | 2024-02-15T23:38:28: },
0|colyseus-app | 2024-02-15T23:38:28: parentIndex: 5,
0|colyseus-app | 2024-02-15T23:38:28: root: ReferenceTracker {
0|colyseus-app | 2024-02-15T23:38:28: refs: Map(0) {},
0|colyseus-app | 2024-02-15T23:38:28: refCounts: {},
0|colyseus-app | 2024-02-15T23:38:28: deletedRefs: Set(0) {},
0|colyseus-app | 2024-02-15T23:38:28: nextUniqueId: 24
0|colyseus-app | 2024-02-15T23:38:28: },
0|colyseus-app | 2024-02-15T23:38:28: refId: 2
0|colyseus-app | 2024-02-15T23:38:28: },
0|colyseus-app | 2024-02-15T23:38:28: '$items': Map(0) {},
0|colyseus-app | 2024-02-15T23:38:28: '$indexes': Map(0) {},
0|colyseus-app | 2024-02-15T23:38:28: '$refId': 5,
0|colyseus-app | 2024-02-15T23:38:28: '$proxy': true
0|colyseus-app | 2024-02-15T23:38:28: }
0|colyseus-app | 2024-02-15T23:38:28: assertInstanceType field 3
0|colyseus-app | 2024-02-15T23:38:28: TypeError: Cannot read properties of undefined (reading 'constructor')
0|colyseus-app | 2024-02-15T23:38:28: at assertInstanceType (/Users/huhui/code/lykke-texas/colyseus-server/node_modules/@colyseus/schema/build/cjs/index.js:2421:99)
0|colyseus-app | 2024-02-15T23:38:28: at Schema.encode (/Users/huhui/code/lykke-texas/colyseus-server/node_modules/@colyseus/schema/build/cjs/index.js:2824:21)
0|colyseus-app | 2024-02-15T23:38:28: at TexasRoomState.encode (/Users/huhui/code/lykke-texas/colyseus-server/build/rooms/schema/TexasRoomState.js:28:22)

Optional: Minimal reproduction

No response

@endel
Copy link
Member

endel commented Feb 15, 2024

Hi @DivXPro, can you fork this environment to provide a way to reproduce the error? https://stackblitz.com/edit/colyseus-schema-issue-report?file=index.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants