1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Fix #1870: TypeError in PubSub (#2016)

* Fix #1870: TypeError in PubSub

* Add test

This test is for a race condition; it should reliably pass now,
but is not guaranteed to fail with the previous version.
This commit is contained in:
John Hiesey
2022-03-07 04:27:04 -08:00
committed by GitHub
parent 88586048e1
commit f79e14c8c3
2 changed files with 17 additions and 1 deletions

View File

@@ -683,6 +683,21 @@ describe('Client', () => {
}
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('should not fail when message arrives right after subscribe', async publisher => {
const subscriber = publisher.duplicate();
await subscriber.connect();
try {
await assert.doesNotReject(Promise.all([
subscriber.subscribe('channel', () => {}),
publisher.publish('channel', 'message')
]));
} finally {
await subscriber.disconnect();
}
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('should be able to quit in PubSub mode', async client => {
await client.subscribe('channel', () => {
// noop