-
Notifications
You must be signed in to change notification settings - Fork 136
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
Refresh session when 401 errors happens #4790
Conversation
Coverage report
Test suite run success1901 tests passing in 867 suites. Report generated by 🧪jest coverage report action from 45e9fa7 |
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.
Great job, I think this is the right approach, refreshing on demand 🎉
It would be great if we could disallow destructuring the session object somehow... but I'm not sure if we can do that in JS 🤔
this will no longer be necessary with #4769 solved).
Nice!
/snapit |
🫰✨ Thanks @frandiox! Your snapshot has been published to npm. Test the snapshot by intalling your package globally: pnpm i -g @shopify/[email protected]
|
@Shopify/app-inner-loop Could you please take a look at this one to unblock merge? 🙇 |
(I just rebased the branch because it got a conflict — it's ready to merge again) |
WHY are these changes introduced?
Fixes #4618
The Assets API may return 401 statuses after running for a while, and that may happen before the session gets refreshed. To prevent the development server from terminating, if we get that status, we manually refresh the session.
WHAT is this pull request doing?
This PR solves this by calling
session.refresh()
when it gets a 401 error. We'd face a circular dependency if we were to get the types correctly, so this PR checks therefresh
at runtime and just calls it (this will no longer be necessary with #4769 solved).How to test your changes?
SESSION_TIMEOUT_IN_MS
value (indev-server-session.ts
) to300 * 60 * 1000
shopify theme dev --verbose
console.log
logs to make things a bit clearer)Post-release steps
N/A
Measuring impact
How do we know this change was effective? Please choose one:
Checklist