Skip to content

Android LocalStorage throwing #6633

@jridgewell

Description

@jridgewell
TypeError: Failed to load store: : Cannot read property 'getItem' of null
    at https://cdn.ampproject.org/rtv/011481320064935/v0.js:259:102
    at sh.loadBlob (https://cdn.ampproject.org/rtv/011481320064935/v0.js:259:53)
    at ph (https://cdn.ampproject.org/rtv/011481320064935/v0.js:256:32)
    at nh.f.get (https://cdn.ampproject.org/rtv/011481320064935/v0.js:255:748)
    at https://cdn.ampproject.org/rtv/011481320064935/v0/amp-user-notification-0.1.js:13:84

We're passing our "is local storage supported" check, but local storage is not supported.

We should instead do a more complete check inside a promise in the constructor:

const isSupported = new Promise((resolve) => {
  this.win.localStorage.getItem('test');
  resolve(true);
}).catch(() => {
  dev().expectedError(...);
  return false;
});

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions