# Uncaught(in promise) Phaser TicTacToe

**URL:** <https://forum.heroiclabs.com/t/uncaught-in-promise-phaser-tictactoe/2858>\
**Category:** Local Setup\
**Created:** [July 21, 2022, 12:37pm UTC](https://forum.heroiclabs.com/t/uncaught-in-promise-phaser-tictactoe/2858 "2022-07-21T12:37:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ongun1905](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/ongun1905/32/1252_2.png) [@Ongun1905](https://forum.heroiclabs.com/u/Ongun1905)\
**Post date:** [July 21, 2022, 12:37pm UTC](https://forum.heroiclabs.com/t/uncaught-in-promise-phaser-tictactoe/2858/1 "2022-07-21T12:37:42Z")

</div>

Hi everyone,  
I’m fairly new to Nakama and I’m trying to run the Github source code for tictactoe made with Nakama and Phaser. When I start a new game, I get the error that says that I have an uncaught(in promise) for findmatch(), which I looked into for a while to understand, but I still couldn’t figure out the error. What am I supposed to do right now? I’m running the server with docker at the moment.

---

<div class="post-metadata">

**Author:** ![tom](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/tom/32/676_2.png) [@tom](https://forum.heroiclabs.com/u/tom)\
**Post date:** [July 25, 2022, 10:37am UTC](https://forum.heroiclabs.com/t/uncaught-in-promise-phaser-tictactoe/2858/2 "2022-07-25T10:37:48Z")

</div>

Hi @Ongun1905,

Please can you confirm that you’re running the [nakama-project-template](https://github.com/heroiclabs/nakama-project-template) server? This server has some custom server runtime code that will provide the `findMatch` function you’re missing.

We’ve recently updated the [Tic-Tac-Toe tutorial](https://heroiclabs.com/docs/nakama/tutorials/javascript/xoxo/) to make this step a bit clearer.

If you’re still experiencing issues please do let me know.

---

<div class="post-metadata">

**Author:** ![Ongun1905](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/ongun1905/32/1252_2.png) [@Ongun1905](https://forum.heroiclabs.com/u/Ongun1905)\
**Post date:** [July 25, 2022, 1:19pm UTC](https://forum.heroiclabs.com/t/uncaught-in-promise-phaser-tictactoe/2858/3 "2022-07-25T13:19:43Z")

</div>

Hi @tom ,  
Thank you for the response. I fixed it right now, I am running the Nakama project template server at the moment.

One issue I’m having right now is that when I try to find a match I get an error in the console which says that “WebSocket is closed or already in the closing state”. I am running two localhosts in the incognito tab. However, I fixed this issue by removing an if statement and only keeping the body of that if statement in nakama.js which checks if the deviceId already exists. I got it to work on some point where the board updates on both localhosts but updating turns doesn’t work.

---

<div class="post-metadata">

**Author:** ![tom](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/tom/32/676_2.png) [@tom](https://forum.heroiclabs.com/u/tom)\
**Post date:** [July 25, 2022, 2:02pm UTC](https://forum.heroiclabs.com/t/uncaught-in-promise-phaser-tictactoe/2858/4 "2022-07-25T14:02:00Z")

</div>

Hi @Ongun1905, glad you got it working.

Yes indeed, the issue you mentioned is due to the same device ID being used to connect twice. Our updated docs mention this. While testing locally I would advise setting `deviceId` to `uuidv4()` so that a new device ID is generated for each client.

---

<div class="post-metadata">

**Author:** ![Ongun1905](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/ongun1905/32/1252_2.png) [@Ongun1905](https://forum.heroiclabs.com/u/Ongun1905)\
**Post date:** [July 25, 2022, 2:37pm UTC](https://forum.heroiclabs.com/t/uncaught-in-promise-phaser-tictactoe/2858/5 "2022-07-25T14:37:08Z")

</div>

I also fixed the issue of player turns by setting userId in setPlayerTurn() to nakama.session.user\_id

Thanks so much Tom!
