From e7c9e0960242e46047ae9fd23db151bcc1503fb4 Mon Sep 17 00:00:00 2001 From: Mark Nadal Date: Mon, 15 Feb 2016 14:28:54 -0800 Subject: [PATCH 1/3] changelog bump --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a4be436..21ca8b16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 0.3.6 + + - Fixed S3 typo. + ## 0.3.5 - Fixed server push. From fd103d276b3967ee830c346967658e2e6e247c4f Mon Sep 17 00:00:00 2001 From: Mark Nadal Date: Wed, 24 Feb 2016 22:57:59 -0800 Subject: [PATCH 2/3] catch localStorage --- gun.js | 6 +++--- package.json | 2 +- test/common.js | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/gun.js b/gun.js index 65499909..c4300d04 100644 --- a/gun.js +++ b/gun.js @@ -1139,8 +1139,8 @@ ;(function(exports){ function s(){} - s.put = function(key, val){ return store.setItem(key, Gun.text.ify(val)) } - s.get = function(key, cb){ /*setTimeout(function(){*/ return cb(null, Gun.obj.ify(store.getItem(key) || null)) /*},1)*/} + s.put = function(key, val, cb){ try{ store.setItem(key, Gun.text.ify(val)) }catch(e){if(cb)cb(e)} } + s.get = function(key, cb){ /*setTimeout(function(){*/ try{ cb(null, Gun.obj.ify(store.getItem(key) || null)) }catch(e){cb(e)} /*},1)*/} s.del = function(key){ return store.removeItem(key) } var store = this.localStorage || {setItem: function(){}, removeItem: function(){}, getItem: function(){}}; exports.store = s; @@ -1191,7 +1191,7 @@ (opt.headers = Gun.obj.copy(tab.headers)).id = tab.msg(); Gun.is.graph(graph, function(node, soul){ if(!gun.__.graph[soul]){ return } - tab.store.put(tab.prefix + soul, gun.__.graph[soul]); + tab.store.put(tab.prefix + soul, gun.__.graph[soul], function(err){if(err){ cb({err: err}) }}); }); if(!(cb.local = opt.local)){ tab.request.s[opt.headers.id] = tab.error(cb, "Error: Put failed!"); diff --git a/package.json b/package.json index 8c3a9a4f..2db6a0ae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gun", - "version": "0.3.6", + "version": "0.3.7", "description": "Graph engine", "main": "index.js", "scripts": { diff --git a/test/common.js b/test/common.js index f4ff81e4..2caa79e8 100644 --- a/test/common.js +++ b/test/common.js @@ -3780,6 +3780,22 @@ describe('Gun', function(){ } }); }); + + it("localStorage", function(done){ + var localStorage = localStorage || {clear:function(){}}; + localStorage.clear(); + var gun = Gun(); + + + var text = Gun.text.random(1024 * 1024 * 6); + gun.put({i: text}, function(err, ok){ + if(done.c){ return } + if(!err){ return done() } + var text = "If you are seeing this message, it means the localStorage error was caught successfully rather than it crashing and stopping replication to peers. Also, the error is now reported back to you via the put callback. Here it is!"; + localStorage.clear(); + done(); done.c = 1; + }); + }); }); describe('Streams', function(){ From 3cc1b716ea93ce7a7833f367c292ee5a4bc5f38b Mon Sep 17 00:00:00 2001 From: Mark Nadal Date: Wed, 24 Feb 2016 22:59:58 -0800 Subject: [PATCH 3/3] catch localStorage errors --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21ca8b16..7d4acd93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 0.3.7 + + - Catch localStorage errors. + ## 0.3.6 - Fixed S3 typo.