parse-community / parse-server

Parse Server for Node.js / Express
https://parseplatform.org
Apache License 2.0
20.95k stars 4.78k forks source link

Cache idempotent requests responses #9294

Open abubkr-hago opened 2 months ago

abubkr-hago commented 2 months ago

New Feature / Enhancement Checklist

Current Limitation

Idempotent requests are now rejected with a 159 code error,

Feature / Enhancement Description

Instead of rejecting with an error, maybe there is a way to cache the response and respond with it on the next request?.

Example Use Case

A client SDK creates a Test ParseObject but doesn't recieve the response because of a network issue, the SDK tries to create the object again with the same X-Parse-Request-Id header, the server replies with the same object creation response instead of creating a new one.

Alternatives / Workarounds

N/A

3rd Party References

N/A

parse-github-assistant[bot] commented 2 months ago

Thanks for opening this issue!

mtrezza commented 2 months ago

Could you provide more details in your example use case? Specifically:

the server replies with the same object creation response instead of creating a new one.

abubkr-hago commented 2 months ago

I have an android app where I am creating a Post ParseObject, but when connection issues arise creating a post can sometimes return with the error code 159. And then the app will have to figure out how to query this newly crerated post.

I think caching the response server side on the same _Idempotency collection for the same amount of time the ttl is set in the idempotencyOptions configuration... might solve this issue.

mtrezza commented 2 months ago

Got it. This has been discussed in the design of this feature, see https://github.com/parse-community/parse-server/pull/6748#issuecomment-657918836 and https://github.com/parse-community/parse-server/pull/6748#issuecomment-658087261. Maybe @mrmarcsmith would be interested to join this discussion here to find a concept for returning cached responses.