Better reconnect after invalid lastKnownHash

This commit is contained in:
yflory
2020-03-13 17:39:16 +01:00
parent d53e9cff02
commit 578042154e
6 changed files with 66 additions and 32 deletions

View File

@@ -424,7 +424,7 @@ const storeMessage = function (Env, channel, msg, isCp, optionalMessageHash) {
* it has a side-effect of filling the index cache if it's empty
1. if you provided a lastKnownHash and that message does not exist in the history:
* either the client has made a mistake or the history they knew about no longer exists
* call back with EINVAL
* call back with EUNKNOWN
2. if you did not provide a lastKnownHash
* and there are fewer than two checkpoints:
* return 0 (read from the start of the file)
@@ -460,7 +460,7 @@ const getHistoryOffset = (Env, channelName, lastKnownHash, cb) => {
// QUESTION: does this mean mailboxes are causing the server to store too much stuff in memory?
if (lastKnownHash && typeof(lkh) !== "number") {
waitFor.abort();
return void cb(new Error('EINVAL'));
return void cb(new Error('EUNKNOWN'));
}
// Since last 2 checkpoints