Vector.Dot error

I have a multiplayer game using phaser 3 for front end, and Colyseus, Matterjs, and MongoDb for backend. The game typically works great but every once in a while (every 50 games or so) there seems to be an issue with collision between the players and tilemap on the front end. The game freezes and this is the error that pops up:

Uncaught TypeError: Cannot read properties of undefined (reading ‘x’)
at Vector.dot (phaser.js:19515:1)
at SAT._projectToAxis (phaser.js:63700:1)
at SAT._overlapAxes (phaser.js:63669:1)
at SAT.collides (phaser.js:63566:1)
at Detector.collisions [as detector] (phaser.js:63473:1)
at Engine.update (phaser.js:185515:1)
at World.update (phaser.js:186911:1)
at EventEmitter.emit (phaser.js:1935:1)
at Systems.step (phaser.js:45126:1)
at SceneManager.update (phaser.js:91489:1)

This doesn’t reference any lines of my code and it happens so inconsistently that it has been tricky to debug. It looks like it probably has to do with collision between the player and tilemap but not 100% sure. Here is the code for tilemap collision:

const map = this.make.tilemap({ key: ‘map’ })
this.map = map

const tileset = map.addTilesetImage(‘RPG_Nature_Tileset’, ‘tiles’, 32, 32, 1, 2)
this.layer1 = map.createLayer(‘Tile Layer 1’, tileset, 0, 0)
this.layer2 = map.createLayer(‘Tile Layer 2’, tileset, 0, 0)
this.layer3 = map.createLayer(‘Tile Layer 3’, tileset, 0, 0)
this.layer4 = map.createLayer(‘Tile Layer 4’, tileset, 0, 0)

this.layer1.setCollisionByProperty({ collides: true })
this.layer2.setCollisionByProperty({ collides: true })
this.layer3.setCollisionByProperty({ collides: true })
this.layer4.setCollisionByProperty({ collides: true })

this.matter.world.convertTilemapLayer(this.layer1)
this.matter.world.convertTilemapLayer(this.layer2)
this.matter.world.convertTilemapLayer(this.layer3)
this.matter.world.convertTilemapLayer(this.layer4)

And code for adding resources:

addResources() {
const trees = this.map.getObjectLayer(‘trees’)
const rocks = this.map.getObjectLayer(‘rocks’)

    this.treeItems = []
    trees.objects.forEach((tree) => {
        let treeItem = this.physics.add.image(tree.x, tree.y, 'trees', 'trees')
        treeItem.setDepth(8)
        this.treeItems.push(treeItem)
        treeItem.x += treeItem.width / 2
        treeItem.y -= treeItem.height / 2
        //treeItem.setStatic(true)
        this.add.existing(treeItem)
    })

    this.rockItems = []
    rocks.objects.forEach((rock) => {
        let rockItem = this.physics.add.image(rock.x, rock.y, 'rocks', 'rocks')
        rockItem.setDepth(2)
        this.rockItems.push(rockItem)
        rockItem.x += rockItem.width / 2
        rockItem.y -= rockItem.height / 2
        //rockItem.setStatic(true)
        this.add.existing(rockItem)
    })
}

The game has frozen and thrown this error during both collision with tilemap layers, and collision with resources.