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

Adding a project should be idempotent #19

Closed
2 tasks done
EvanHahn opened this issue Oct 17, 2024 · 3 comments
Closed
2 tasks done

Adding a project should be idempotent #19

EvanHahn opened this issue Oct 17, 2024 · 3 comments

Comments

@EvanHahn
Copy link
Contributor

EvanHahn commented Oct 17, 2024

Adding a server peer basically has 3 steps:

  1. Tell the server to add itself to the project.
  2. Assign a role to the server peer.
  3. Wait for an initial sync with the server peer.

A bug can arise if steps 2 or 3 fail, or if step 1 succeeds on the server but fails on the client (likely due to network failure). If this happens, trying to re-add the server will fail because the server will respond with “you can’t do this, we already have this project”.

To fix this, we should make adding a project idempotent on the server side.

That means:

  • Changing POST /projects to PUT /projects (careful about backwards compatibility with existing builds)
  • Make adding duplicate projects a no-op.

See the equivalent issue on @comapeo/core: digidem/comapeo-core#916.

@EvanHahn
Copy link
Contributor Author

@EvanHahn
Copy link
Contributor Author

EvanHahn commented Oct 22, 2024

Mostly done in digidem/comapeo-core@749c467 and digidem/comapeo-core@9192404.

It should be easy to change POST /projects to PUT /projects, so this work is mostly done. I plan to wait until November 1 to make this change, as it's a breaking change that would affect our COP16 demos.

EvanHahn added a commit to digidem/comapeo-core that referenced this issue Oct 23, 2024
EvanHahn added a commit to digidem/comapeo-core that referenced this issue Oct 24, 2024
@EvanHahn
Copy link
Contributor Author

Closed in digidem/comapeo-core@4827194.

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

No branches or pull requests

1 participant