Skip to content

Not receiving updated data in React #35

@katfang

Description

@katfang

Describe the bug

From a React app, I make a call to the Reboot backend, which I expect to update some data elsewhere in the React app, but it does not get updated.

From the web inspector, it looks like the protobuf with the new data is getting sent.

To Reproduce / Expected behavior

Steps to reproduce the behavior:

Visually:

  1. clone https://github.com/katfang/reboot-testbed/tree/main/cancel-pending
    2. more info in the README there
  2. npm install
  3. npx rbt dev run and npm run dev in two different terminals
  4. Open localhost:3000
  5. click on a pawn, click another square to move the pawn
    7. see green squares highlighting the move
    8. see on the right side, move shows up with "Cancel link"
  6. click cancel link.
  7. Expectation 1. The green squares go away.
    2. In the console, see that "outstanding moves" updates with a "status: 5" instead of "status: 1" (1 corresponds with pending, 5 corresponds with canceled)
  8. What actually happens: green squares stay, and "outstanding moves" logs with "status: 1"

However

  1. the backend logs that it sees status: 5
  2. If you check the web inspector's network for GetOutstandingMoves websocket's, it seems to get the data that "status: 5"

Other oddities:

  1. On my computer, increasing the number of pawns (in backend/src/game_servicer.ts -- PIECES_PER_TEAM) seems to increase how reliably you get this problem.
  2. Simplifying the code (some combination of reducing the Game object size, removing RPC methods on the BE, removing calls from the FE) often made the problem rarer. (e.g. commit 9533f5)
    3. In the most clear cut instance, removing a call to Reboot from the React app (and a React component) seemed to make the problem rarer. (commit 33b280)
  3. NOT all data is stale. Under "Pending Moves" the move is removed immediately, which implies some parts are receiving the right updates initiated by the cancel. The data for "Pending Moves" vs what backs making the green squares disappear is different:
    5. "Pending Moves" (right hand side) calls Game.Queues which reads from Game.moves_queue (in app/CheaosQueues.tsx)
    6. What triggers the green squares to disappear is hooked up to Game.GetOutstandingMoves, which reads the move_ids from Game.outstanding_player_moves and pulls the corresponding data from Move object collection.

My best given log lines is that Reboot is causing React to re-render, but somehow the data is stale. Given oddity 1, it seems that somehow the amount of data matters

Impact

How severely does this bug impact your use of Reboot?

  • It's not having any negative impact
  • It's annoying
  • It's a serious problem
  • It makes it impossible for me to use Reboot

Please explain why?

I expect Reboot-React library to give my application code the update.

Client

Please complete the following information:

  • OS: mac 14.7
  • Client: Firefox 138.0.4
  • Client version: npx rbt --version 0.25.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions