From 0546f99b340d17b38140eb8c600089538b316a86 Mon Sep 17 00:00:00 2001 From: Dawid Kisielewski Date: Tue, 10 Oct 2023 18:22:30 +0200 Subject: [PATCH] Add hardrollback fetch error --- lib/client/doc.js | 6 +++++- lib/error.js | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/client/doc.js b/lib/client/doc.js index 5fbd8b7cc..871c76a0b 100644 --- a/lib/client/doc.js +++ b/lib/client/doc.js @@ -1048,7 +1048,11 @@ Doc.prototype._hardRollback = function(err) { // This is critical error as it means that our doc is not in usable state // anymore, we should throw doc error. logger.error('Hard rollback doc fetch failed.', fetchError, inflightOp); - doc.emit('error', fetchError); + + doc.emit('error', new ShareDBError( + ERROR_CODE.ERR_HARD_ROLLBACK_FETCH_FAILED, + 'Hard rollback fetch failed: ' + fetchError.message + )); } if (err.code === ERROR_CODE.ERR_OP_SUBMIT_REJECTED) { diff --git a/lib/error.js b/lib/error.js index 85ccbda42..0715faf38 100644 --- a/lib/error.js +++ b/lib/error.js @@ -39,6 +39,7 @@ ShareDBError.CODES = { ERR_OP_NOT_ALLOWED_IN_PROJECTION: 'ERR_OP_NOT_ALLOWED_IN_PROJECTION', ERR_OP_SUBMIT_REJECTED: 'ERR_OP_SUBMIT_REJECTED', ERR_PENDING_OP_REMOVED_BY_OP_SUBMIT_REJECTED: 'ERR_PENDING_OP_REMOVED_BY_OP_SUBMIT_REJECTED', + ERR_HARD_ROLLBACK_FETCH_FAILED: 'ERR_HARD_ROLLBACK_FETCH_FAILED', ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM: 'ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM', ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM: 'ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM', ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT: 'ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT',