Skip to content
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

catch failed setItem #3660

Merged
merged 1 commit into from Jun 21, 2016
Merged

Conversation

erwinmombay
Copy link
Member

No description provided.

return new Promise(resolve => {
return new Promise((resolve, reject) => {
if (!this.win.localStorage) {
reject('No localStorage object found');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure these two rejects are needed. If an error is thrown inside the resolver (and resolve has not been called yet), the promise rejects with that error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah these do get caught already its just the type of error i wanted to clarify. (from logging pov). I probably won't merge this anyways and just filter them from our logs to a new metric

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed rejections

@erwinmombay erwinmombay reopened this Jun 20, 2016
@erwinmombay erwinmombay force-pushed the localstorage-get-set branch 2 times, most recently from 7f2e189 to 54e45cb Compare June 20, 2016 18:22
@erwinmombay erwinmombay changed the title reject retrieval of Blob if localStorage doesnt exist catch failed setItem Jun 20, 2016
@jridgewell
Copy link
Contributor

LGTM.

@@ -135,6 +135,9 @@ export class Storage {
const blob = btoa(JSON.stringify(store.obj));
return this.binding_.saveBlob(this.origin_, blob);
})
.catch(reason => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update on the binding level.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe this is obsolete.

@erwinmombay
Copy link
Member Author

@dvoytenko PTAL. not sure if we still want to report localStorage support.

@dvoytenko
Copy link
Contributor

@erwinmombay We still do want to report it. Our goal is to ensure it's not growing. If it would - that'd likely indicate a new client that has storage misconfigured.

@@ -302,13 +305,21 @@ export class LocalStorageBinding {
/** @override */
loadBlob(origin) {
return new Promise(resolve => {
if (!this.isLocalStorageSupported_) {
resolve();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since loadBlob is defined as a promise resolving null or string - let's do resolve(null);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@dvoytenko
Copy link
Contributor

LGTM pending test for dev.error

@erwinmombay erwinmombay merged commit 45422dc into ampproject:master Jun 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants