From 92da5ffdfa309434a69b5f744f503a7553cbd706 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Fri, 7 Jun 2019 12:55:40 +0100 Subject: [PATCH] Suppress message in expected cases of nonexistent localid --- packages/server/src/federation.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/server/src/federation.js b/packages/server/src/federation.js index a8b6488..e38bb4a 100644 --- a/packages/server/src/federation.js +++ b/packages/server/src/federation.js @@ -192,10 +192,21 @@ spawn named '@syndicate-lang/server/federation/ScopeFactory' { field this.subs = Map(); const scopeThis = this; - const callWithSub = (localid, linkid, f) => { + const callWithSub = (localid, linkid, f, notFoundIsBad) => { const sub = this.subs.get(localid, false); if (!sub) { - console.error("Ignoring mention of nonexistent local ID", localid, linkid); + // Mention of a nonexistent local ID could be an error, or could be OK. It's fine if + // we receive Add/Del/Msg for an endpoint we've sent a Clear for but haven't yet seen + // the matching End; it's not OK if we receive a Clear for an ep that maps to a + // localid which is then not found. + if (notFoundIsBad) { + console.error("Ignoring mention of nonexistent local ID", localid, linkid); + } else { + // Nothing to do except wait for an appropriate End to arrive. Perhaps in future we + // could record the fact we're waiting for an End, so that we could positively know + // that a given nonexistent ID is a non-error, rather than assuming it's a + // non-error in all cases except Clear. + } } else { return f(sub); } @@ -218,7 +229,7 @@ spawn named '@syndicate-lang/server/federation/ScopeFactory' { default: break; } - }); + }, true); }; const removeMatch = (localid, captures, linkid) => {