Fetch a new request token as soon as the browser becomes online#18778
Fetch a new request token as soon as the browser becomes online#18778
Conversation
|
O this is very neat. And also very useful for apps indeed! I guess 19 is good enough for this for now. |
|
What about listening to |
|
Conflicts 😨 |
We're not polling. We use the online event already to fetch a token when the network state changes. But we need to pool while online as request tokens time out after a certain time. |
e4f4ae2 to
eb8aa6b
Compare
| console.info('session token successfully updated after resuming network') | ||
|
|
||
| // Let apps know we're online and requests will have the new token | ||
| emit('networkOnline', { |
There was a problem hiding this comment.
Would be nice to document those somewhere
|
@ChristophWurst can you rebase this? Then we can get this is :) |
eb8aa6b to
bf2e282
Compare
gary-kim
left a comment
There was a problem hiding this comment.
Didn't know about the online event. Cool!
|
needs another rebase 💃 |
bf2e282 to
9d7f63b
Compare
|
Now be quick and merge this :P |
9d7f63b to
4538f08
Compare
|
/compile amend / |
4538f08 to
ca3d6bc
Compare
ca3d6bc to
6690e3b
Compare
|
Rebase cool, rebase fine |
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
6690e3b to
d1886b5
Compare
Fixes #16809
Debugging a few Sentry tickets I saw evidence of HTTP 412's -> CSRF check failing. Usually those are unexpected as we periodically fetch the current token, but if the client machine is paused or the browser goes offline, the CSRF token might not be fetched when the connection returns. Thus I added event handlers that can pause the background requests when there is no network connectivity and send off a request for the new token as soon as there is connectivity.
How to test
As this is something apps might have interest in, e.g. when to resume operation after offline as you have a dependency on the CSRF token, I added events emitted to the event bus where apps can listen to both the browser going offline as well as coming back online.
Do we want this in 18 already? Then we can backport.