Skip to content

Commit

Permalink
chore(notifier): Annote subscriber rejections that follow disconnection
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 committed Apr 13, 2023
1 parent c022a5d commit 36ee17b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/notifier/src/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { isUpgradeDisconnection } from '@agoric/internal/src/upgrade-api.js';

import './types-ambient.js';

const { details: X } = assert;
const sink = () => {};

/**
Expand All @@ -14,6 +15,7 @@ const sink = () => {};
* @returns {Promise<T>}
*/
const reconnectAsNeeded = async thunk => {
let initialDisconnection;
let lastVersion = -Infinity;
// End synchronous prelude.
await null;
Expand All @@ -24,6 +26,9 @@ const reconnectAsNeeded = async thunk => {
return result;
} catch (err) {
if (isUpgradeDisconnection(err)) {
if (!initialDisconnection) {
initialDisconnection = err;
}
const { incarnationNumber: version } = err;
if (version > lastVersion) {
// We don't expect another upgrade in between receiving
Expand All @@ -33,6 +38,12 @@ const reconnectAsNeeded = async thunk => {
continue;
}
}
if (initialDisconnection && initialDisconnection !== err) {
assert.note(
err,
X`Attempting to recover from disconnection: ${initialDisconnection}`,
);
}
throw err;
}
}
Expand Down

0 comments on commit 36ee17b

Please sign in to comment.