Skip to content

Commit 65e4910

Browse files
dmmulroybalazsorban44
andcommittedFeb 1, 2021
fix: Add a null check to the window 'storage' event listener (#1198)
* Add a null check to the window 'storage' event listener While testing in Cypress it's possible to receive a null value on Storage Events when 'clear' is called and will cause errors as seen in #1125. * Update index.js typo * Update src/client/index.js Co-authored-by: Balázs Orbán <info@balazsorban.com> * formatting Co-authored-by: Balázs Orbán <info@balazsorban.com>
1 parent 30c6d63 commit 65e4910

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎src/client/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ if (typeof window !== 'undefined') {
4848
window.addEventListener('storage', async (event) => {
4949
if (event.key === 'nextauth.message') {
5050
const message = JSON.parse(event.newValue)
51-
if (message.event && message.event === 'session' && message.data) {
51+
if (message?.event === 'session' && message.data) {
5252
// Ignore storage events fired from the same window that created them
5353
if (__NEXTAUTH._clientId === message.clientId) {
5454
return

0 commit comments

Comments
 (0)
Please sign in to comment.