matrix-org / matrix-org/matrix-js-sdk

Make idempotent API endpoints return the same pending promise

Open
#262 0 comments 0 reactions 0 assignees View on GitHub
T-Enhancement
Dominant language
TypeScript
Stars
2.2k
Forks
704
Avg merge
1d 20h
Merged PRs (30d)
40

Description

We've had issues in the past where clients can tightloop doing scrollback requests because they spam scrollback() which then spams the server. One of the solutions to this was to return the **same pending promise** if a request was ongoing.

This can be applied to a ton of other APIs, such as receipts. We should have a genericish way of applying this to the JS SDK method calls. One way would be to do a map of path -> Promise, and abuse the fact that most idemponent endpoints have their idempotency in the path. This isn't true for everything (e.g. presence), so we could extend this to inspect some parts of the body. It's a good start though.

https://matrix.org/jira/browse/SYJS-40

Contributor guide

Open the contributing guide

Research direction

Start by tracing the JavaScript SDK method calls for scrollback() and receipts, then review how request paths and bodies identify idempotent endpoints. Define the generic approach and confirm that repeated calls return the same pending promise while a request is ongoing, including cases such as presence where idempotency is not in the path.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.