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

Graphcache: mutations with different files in parallel, results lost #3541

Open
3 tasks done
ursarik opened this issue Mar 20, 2024 · 2 comments
Open
3 tasks done

Graphcache: mutations with different files in parallel, results lost #3541

ursarik opened this issue Mar 20, 2024 · 2 comments
Labels
needs more info ✋ A question or report that needs more info to be addressable

Comments

@ursarik
Copy link

ursarik commented Mar 20, 2024

Describe the bug

Results get lost if you upload multiple files in parallel and use Graphcache.
Seems like it happens because of stringify in variables.ts in core package
If you will add

if (x instance File) {
  const key = cache.get(x) || Math.random().toString(36).slice(2);
  cache.set(x, key);
  return stringify({ __key: key });
}

everything works fine

Reproduction

https://codesandbox.io/p/devbox/mystifying-borg-g7zgym?file=%2Fsrc%2FFileUpload.jsx%3A22%2C1

Urql version

urql v4.0.6, urql/exchange-graphcache v6.5.0

Validations

  • I can confirm that this is a bug report, and not a feature request, RFC, question, or discussion, for which GitHub Discussions should be used
  • Read the docs.
  • Follow our Code of Conduct
@JoviDeCroock
Copy link
Collaborator

We used to do that before #3169 however that didn't work out. I guess the issue is that we are using operation.key in GraphCache for mutations while we decided a while ago to use a different type of _identity for that.

I guess this could be the cause for missing a few results with parallel identical (observably identical) mutations

@kitten
Copy link
Member

kitten commented Mar 27, 2024

@JoviDeCroock: The layering of mutations is still relevant, but if results conflict, they can override each other.

@ursarik: This really depends on how you use the result, typically; Each duplicate mutation gets the same key, unless the variables change it, but still flows through the operation chain separately.

This doesn't really matter until Graphcache writes results to its cache in layers, which may then be re-used across multiple mutations with the same key.

Meaning, we might need you to be more specific than:

Results get lost

Especially since it's unclear what the reproduction is trying to reproduce and errors out with a 502 error.

@kitten kitten added the needs more info ✋ A question or report that needs more info to be addressable label Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info ✋ A question or report that needs more info to be addressable
Projects
None yet
Development

No branches or pull requests

3 participants