collab_client: Delete unused caughtErrors

This commit is contained in:
Richard Hansen 2021-03-26 19:46:46 -04:00
parent 81b9a2544d
commit 3ee6b5eb2b

View file

@ -50,9 +50,6 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad)
const userSet = {}; // userId -> userInfo const userSet = {}; // userId -> userInfo
userSet[userId] = initialUserInfo; userSet[userId] = initialUserInfo;
const caughtErrors = [];
const caughtErrorCatchers = [];
const caughtErrorTimes = [];
const msgQueue = []; const msgQueue = [];
let isPendingRevision = false; let isPendingRevision = false;
@ -84,7 +81,7 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad)
setChannelState('DISCONNECTED', 'initsocketfail'); setChannelState('DISCONNECTED', 'initsocketfail');
} else { } else {
// check again in a bit // check again in a bit
setTimeout(wrapRecordingErrors('setTimeout(handleUserChanges)', handleUserChanges), 1000); setTimeout(handleUserChanges, 1000);
} }
return; return;
} }
@ -99,16 +96,14 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad)
callbacks.onConnectionTrouble('SLOW'); callbacks.onConnectionTrouble('SLOW');
} else { } else {
// run again in a few seconds, to detect a disconnect // run again in a few seconds, to detect a disconnect
setTimeout(wrapRecordingErrors('setTimeout(handleUserChanges)', handleUserChanges), 3000); setTimeout(handleUserChanges, 3000);
} }
return; return;
} }
const earliestCommit = lastCommitTime + 500; const earliestCommit = lastCommitTime + 500;
if (t < earliestCommit) { if (t < earliestCommit) {
setTimeout( setTimeout(handleUserChanges, earliestCommit - t);
wrapRecordingErrors('setTimeout(handleUserChanges)', handleUserChanges),
earliestCommit - t);
return; return;
} }
@ -153,24 +148,22 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad)
} }
} else { } else {
// run again in a few seconds, to check if there was a reconnection attempt // run again in a few seconds, to check if there was a reconnection attempt
setTimeout(wrapRecordingErrors('setTimeout(handleUserChanges)', handleUserChanges), 3000); setTimeout(handleUserChanges, 3000);
} }
if (sentMessage) { if (sentMessage) {
// run again in a few seconds, to detect a disconnect // run again in a few seconds, to detect a disconnect
setTimeout(wrapRecordingErrors('setTimeout(handleUserChanges)', handleUserChanges), 3000); setTimeout(handleUserChanges, 3000);
} }
}; };
const acceptCommit = () => { const acceptCommit = () => {
editor.applyPreparedChangesetToBase(); editor.applyPreparedChangesetToBase();
setStateIdle(); setStateIdle();
callCatchingErrors('onInternalAction', () => { try {
callbacks.onInternalAction('commitAcceptedByServer'); callbacks.onInternalAction('commitAcceptedByServer');
});
callCatchingErrors('onConnectionTrouble', () => {
callbacks.onConnectionTrouble('OK'); callbacks.onConnectionTrouble('OK');
}); } catch (err) { /* intentionally ignored */ }
handleUserChanges(); handleUserChanges();
}; };
@ -190,25 +183,6 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad)
}); });
}; };
const wrapRecordingErrors = (catcher, func) => function (...args) {
try {
return func.call(this, ...args);
} catch (e) {
caughtErrors.push(e);
caughtErrorCatchers.push(catcher);
caughtErrorTimes.push(+new Date());
// console.dir({catcher: catcher, e: e});
throw e;
}
};
const callCatchingErrors = (catcher, func) => {
try {
wrapRecordingErrors(catcher, func)();
} catch (e) { /* absorb*/
}
};
const handleMessageFromServer = (evt) => { const handleMessageFromServer = (evt) => {
if (!getSocket()) return; if (!getSocket()) return;
if (!evt.data) return; if (!evt.data) return;
@ -566,8 +540,7 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad)
editor.setProperty('userAuthor', userId); editor.setProperty('userAuthor', userId);
editor.setBaseAttributedText(serverVars.initialAttributedText, serverVars.apool); editor.setBaseAttributedText(serverVars.initialAttributedText, serverVars.apool);
editor.setUserChangeNotificationCallback( editor.setUserChangeNotificationCallback(handleUserChanges);
wrapRecordingErrors('handleUserChanges', handleUserChanges));
setUpSocket(); setUpSocket();
return self; return self;