Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,8 @@ export class Subscriber extends EventEmitter {
const latency = (Date.now() - startTime) / 1000;
this._latencies.add(latency);

this._inventory.remove(message);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we wouldn't want to remove it in the case of a legit modack, just in the case of nack. But yeah, this clearly seems like an oversight.


// No exception means Success.
return AckResponses.Success;
}
Expand Down
26 changes: 24 additions & 2 deletions test/subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -918,10 +918,32 @@ describe('Subscriber', () => {
});

describe('nack', () => {
it('should remove the message from the inventory', async () => {
const inventory: FakeLeaseManager = stubs.get('inventory');
const stub = sandbox.stub(inventory, 'remove').withArgs(message);

await subscriber.nack(message);

assert.strictEqual(stub.callCount, 1);
});
});

describe('nackWithResponse', () => {
it('should remove the message from the inventory', async () => {
const inventory: FakeLeaseManager = stubs.get('inventory');
const stub = sandbox.stub(inventory, 'remove').withArgs(message);

await subscriber.nackWithResponse(message);

assert.strictEqual(stub.callCount, 1);
});
});

describe('ackWithResponse', () => {
it('should modAck the message with a 0 deadline', async () => {
const stub = sandbox.stub(subscriber, 'modAck');

await subscriber.nack(message);
await subscriber.ackWithResponse(message);

const [msg, deadline] = stub.lastCall.args;

Expand All @@ -946,7 +968,7 @@ describe('Subscriber', () => {
const inventory: FakeLeaseManager = stubs.get('inventory');
const stub = sandbox.stub(inventory, 'remove').withArgs(message);

await subscriber.nack(message);
await subscriber.ackWithResponse(message);

assert.strictEqual(stub.callCount, 1);
});
Expand Down
Loading