You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously, I had opened issue #20, PR #25, and then issue #24, all because of an incorrect assumption: I thought that the Gist forking/editing logic depended on the state of the turn system (the previous and current player), but it's only indirectly related. The real condition to check is simply whether the current player owns the Gist or not!
Scenario illustrating the bug if multiple players disconnect on their turns:
Three players are in the game, and Player 1 completes their turn. (Gist owner: Player 1)
Player 2 disconnects before their turn ends. (Gist owner: Player 1)
Player 3 also disconnects before their turn ends. (Gist owner: Player 1)
Player 1 begins their turn, and they should not fork the Gist since they own it! But the game state looks like this: previous player is Player 3, current player is Player 1, and since they don't match, Player 1 should fork and edit the Gist. And that leads to an error from GitHub, because a user can't fork their own Gist!
Instead of starting from first principles and looking at the root of the other actions in this system, I got caught up in the tangled mess of secondary effects, treating the symptoms instead of the cause! I think the situation can be summed up well this way: instead of thinking of my app as one complicated state machine, it's actually more like two or three smaller state machines that communicate with each other. My code should reflect that!
Ultimate solution:
The best solution would be to close issue #21 ("Server should fork/edit Gists on behalf of disconnected users"), so that not only is this bug resolved, but there would also be the extra benefit of accurately giving each player credit for their work even if they're disconnected. (A pure client-side solution still can't solve that issue!)
Background:
Previously, I had opened issue #20, PR #25, and then issue #24, all because of an incorrect assumption: I thought that the Gist forking/editing logic depended on the state of the turn system (the previous and current player), but it's only indirectly related. The real condition to check is simply whether the current player owns the Gist or not!
Scenario illustrating the bug if multiple players disconnect on their turns:
Three players are in the game, and Player 1 completes their turn. (Gist owner: Player 1)
Player 2 disconnects before their turn ends. (Gist owner: Player 1)
Player 3 also disconnects before their turn ends. (Gist owner: Player 1)
Player 1 begins their turn, and they should not fork the Gist since they own it! But the game state looks like this: previous player is Player 3, current player is Player 1, and since they don't match, Player 1 should fork and edit the Gist. And that leads to an error from GitHub, because a user can't fork their own Gist!
Instead of starting from first principles and looking at the root of the other actions in this system, I got caught up in the tangled mess of secondary effects, treating the symptoms instead of the cause! I think the situation can be summed up well this way: instead of thinking of my app as one complicated state machine, it's actually more like two or three smaller state machines that communicate with each other. My code should reflect that!
Ultimate solution:
The best solution would be to close issue #21 ("Server should fork/edit Gists on behalf of disconnected users"), so that not only is this bug resolved, but there would also be the extra benefit of accurately giving each player credit for their work even if they're disconnected. (A pure client-side solution still can't solve that issue!)
Tasks for this issue (intermediary solution):
handleCreateNewGist
orforkAndEditGist
)The text was updated successfully, but these errors were encountered: