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

[Bug?]: Single-flight mutations don't include cookies #1637

Closed
2 tasks done
AlexErrant opened this issue Sep 26, 2024 · 1 comment
Closed
2 tasks done

[Bug?]: Single-flight mutations don't include cookies #1637

AlexErrant opened this issue Sep 26, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@AlexErrant
Copy link
Contributor

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Consider a scenario where the username is stored in a cookie and rendered on the page if it's present. Currently, the username is not shown after a single flight mutation.

Expected behavior 🤔

No response

Steps to reproduce 🕹

Steps:

  1. Clone/apply this commit to examples/todomvc
  2. Observe that the code adds middleware which adds a cookie to be displayed on todomvc.
  3. Here's a video showing how adding something to the todo list (thus triggering a SFM) doesn't have the page show the cookie.
chrome_ZJXI09Lbyy.mp4

Context 🔦

Note that this commit fixes the issue, but I'm not nearly confident enough in it to PR it. It also doubles up the cookies for some reason. Guidance/feedback welcome 😊

Your environment 🌎

No response

@AlexErrant AlexErrant added the bug Something isn't working label Sep 26, 2024
@ryansolid
Copy link
Member

Hmm.. yeah the fix isn't quite right. The idea here is that revalidate is an explicit array or it is true to turn on the mode. What your code does is makes it always true unless those conditions aren't met at which point it revalidates nothing.

I think I might see the issue. I think it is because we clone the event and put a new Request on it reflecting the newly navigated route. This request is missing all the headers so that might be the issue since you are trying to read the cookies in the cache function. I don't know that I want to put all headers across but cookies seem reasonable here. Let's give this fix a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants