Skip to content

Commit

Permalink
fix: let the other side know about a disconnect if we initiate it
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Sep 16, 2020
1 parent 6461fb8 commit 510f427
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/captp/lib/captp.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,12 @@ export function makeCapTP(ourId, rawSend, bootstrapObj = undefined, opts = {}) {
// Pull the plug!
async CTP_DISCONNECT(obj) {
const { reason = disconnectReason(ourId) } = obj;
send(obj);
if (unplug === false) {
// Reject with the original reason.
quietReject(obj.reason, false);
unplug = reason;
// Deliver the object, even though we're unplugged.
rawSend(obj);
}
for (const pr of questions.values()) {
pr.rej(reason);
Expand Down Expand Up @@ -382,8 +383,7 @@ export function makeCapTP(ourId, rawSend, bootstrapObj = undefined, opts = {}) {

// Abort a connection.
const abort = (reason = undefined) => {
const disco = { type: 'CTP_DISCONNECT', reason };
dispatch(disco);
dispatch({ type: 'CTP_DISCONNECT', reason });
};

return harden({ abort, dispatch, getBootstrap, serialize, unserialize });
Expand Down

0 comments on commit 510f427

Please sign in to comment.