-
Notifications
You must be signed in to change notification settings - Fork 281
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
[Breaking Change] Remove session.commit everywhere and instead do it in server before returning the new response. #2137
Conversation
Oxygen deployed a preview of your
Learn more about Hydrogen's GitHub integration. |
0f2adc6
to
8f6a236
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I mentioned remix-oxygen
in the original idea but that's because I thought we'd need access to customerAccount
. Since we just need session.dirty
and its implementation lives in userland... what about just adding the following to server.ts
?
const response = await handleRequest(request);
+if (session.dirty) {
+ response.headers.set('Set-Cookie', await session.commit());
+}
if (response.status === 404) {
...
}
return response;
That way it all lives in userland and we don't do anything special for Oxygen anymore. Those who deploy to Node.js will need to do the same in their entry point, just like when they call storefrontRedirect
.
Also, this is something we'll hopefully be able to move to Remix middleware... and it will simplify a lot upgrading to single fetch until then since we don't need to modify responseStub
, right?
Aside from that, any better name than session.dirty
? Maybe session.isPending
? 🤔
ecde315
to
72d3c42
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The simplification is looking great. One thing to note, though, is that I think this should be considered as a breaking change in Hydrogen because customerAccount
is not calling session.commit()
anymore in some situations, right? And they must add the commit to their entrypoints manually.
Maybe something to keep for the July release. Or if we want to release it earlier, maybe we should keep the commits in customerAccount
for now and extract that in a different PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @frandiox that this is a breaking change. Maybe we just wait to merge it?
👍 I will update the changlog and wait to merge for July release |
ec4f1ac
to
794cb08
Compare
5bed521
to
9e7e023
Compare
…o true whenever session is changed. And set to false whenever session is commited. Then in server code, check if session is dirty, if its dirty, set cookie with sessin.commit. move commit logic to template instead update all the examples bring back location header add changeset
…o true whenever session is changed. And set to false whenever session is commited. Then in server code, check if session is dirty, if its dirty, set cookie with sessin.commit.
WHY are these changes introduced?
Original idea from @frandiox in #2108 (comment)
WHAT is this pull request doing?
HOW to test your changes?
Post-merge steps
Checklist