Skip to content

Commit

Permalink
log error if outgoing circular buffer is full (#1182)
Browse files Browse the repository at this point in the history
  • Loading branch information
BertKleewein authored Apr 5, 2023
1 parent 062a5af commit 71bf42a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions common/transport/amqp/src/sender_link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,13 @@ export class SenderLink extends EventEmitter implements AmqpLink {
this._fsm.transition('detached', undefined, err);
},
send: () => {
if ((this._unsentMessageQueue.length > 0) && !this._rheaSender.sendable() && this._rheaSender.has_credit()) {
// Our sending link has credit, but it isn't sendable. This means the sender link circular buffer is full.
// This can happen if a disposition gets lost, which is very rare, but possible.
// For now, log this condition. If this becomes common, disconnecting and reconnecting the sender here might repair the link.
// (ie. literally call `this._rheaSender.detach(); this._rheaSender.attach();` here.
debugErrors(this.toString() + ': sender link not accepting outgoing messages. It may be stuck because of lost disposition.');
}
while ((this._unsentMessageQueue.length > 0) && this._rheaSender.sendable()) {
debug(this.toString() + ': Unsent message queue length is: ' + this._unsentMessageQueue.length);
/*Codes_SRS_NODE_AMQP_SENDER_LINK_16_020: [When the link gets attached, the messages shall be sent in the order they were queued.] */
Expand Down
1 change: 1 addition & 0 deletions common/transport/amqp/test/_sender_link_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ describe('SenderLink', function () {
fakeRheaLink.sendable = sinon.stub();
fakeRheaLink.sendable.onSecondCall().returns(true);
fakeRheaLink.sendable.returns(false);
fakeRheaLink.has_credit = sinon.stub().returns(true)
fakeRheaLink.send = sinon.stub().returns({ id: 1 });
const fakeRheaSession = new EventEmitter();
fakeRheaSession.open_sender = () => {};
Expand Down

0 comments on commit 71bf42a

Please sign in to comment.