Comparing version 5.0.0 to 5.0.1
@@ -73,3 +73,5 @@ const querystring = require('querystring') | ||
const db = API | ||
let attempt = 0 | ||
const tryIt = async () => { | ||
if (++attempt > 10) throw errors_.new('too many attempts', 400, { docId, fn }) | ||
let doc | ||
@@ -82,5 +84,10 @@ try { | ||
} | ||
const res = await db.put(fn(doc)) | ||
if (res.ok) return res | ||
else return tryIt() | ||
try { | ||
const res = await db.put(fn(doc)) | ||
if (res.ok) return res | ||
else return tryIt() | ||
} catch (err) { | ||
if (err.statusCode === 409) return tryIt() | ||
else throw err | ||
} | ||
} | ||
@@ -87,0 +94,0 @@ return tryIt() |
@@ -24,3 +24,3 @@ { | ||
], | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"main": "lib/cot.js", | ||
@@ -27,0 +27,0 @@ "dependencies": { |
32124
513