Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Change log for amqplib

## Unreleased
- Fix `update-secret-ok` event not being forwarded by `ChannelModel` and `CallbackModel` (fixes #849)
- Add `handler-error` event to connections and channels. If a user-supplied event handler (e.g. `connection.on('close', ...)`, `channel.on('error', ...)`, `channel.on('delivery', ...)` etc.) throws a synchronous error, amqplib will emit a `handler-error` event on the same emitter with the thrown error and the name of the event whose handler threw — provided a `handler-error` listener is registered. If no `handler-error` listener is registered, behaviour is unchanged from previous versions. Note: in previous versions, errors thrown in connection `close` event handlers were silently swallowed; errors thrown in channel event handlers (other than `delivery`/`return`) would kill the channel and possibly the connection (fixes #334).

## v1.0.6
Expand Down
2 changes: 1 addition & 1 deletion lib/callback_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class CallbackModel extends EventEmitter {
constructor(connection) {
super();
this.connection = connection;
['error', 'close', 'blocked', 'unblocked'].forEach((ev) => {
['error', 'close', 'blocked', 'unblocked', 'update-secret-ok'].forEach((ev) => {
connection.on(ev, this.emit.bind(this, ev));
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/channel_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ChannelModel extends EventEmitter {
super();
this.connection = connection;

['error', 'close', 'blocked', 'unblocked'].forEach((ev) => {
['error', 'close', 'blocked', 'unblocked', 'update-secret-ok'].forEach((ev) => {
connection.on(ev, this.emit.bind(this, ev));
});
}
Expand Down
11 changes: 11 additions & 0 deletions test/callback_api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ describe('Callback API', () => {
});
});
});

it('emits update-secret-ok event', (_t, done) => {
connect((err, _c) => {
assert.ifError(err);
c = _c;
c.on('update-secret-ok', () => done());
c.updateSecret(Buffer.from('new secret'), 'no reason', (err) => {
assert.ifError(err);
});
});
});
});

const channel_test_fn = (method) => {
Expand Down
9 changes: 9 additions & 0 deletions test/channel_api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ describe('updateSecret', () => {
.finally(() => c.close())
);
});

it('emits update-secret-ok event', () => {
return connect().then((c) =>
new Promise((resolve, reject) => {
c.on('update-secret-ok', resolve);
c.updateSecret(Buffer.from('new secret'), 'no reason').catch(reject);
}).finally(() => c.close())
);
});
});

describe('assert, check, delete', () => {
Expand Down
Loading