You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
* 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:
@@ -369,7 +369,8 @@ export default class RedisCommandsQueue {
|
||||
#setReturnBuffers() {
|
||||
this.#parser.setReturnBuffers(
|
||||
!!this.#waitingForReply.head?.value.returnBuffers ||
|
||||
!!this.#pubSubState?.subscribed
|
||||
!!this.#pubSubState?.subscribed ||
|
||||
!!this.#pubSubState?.subscribing
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user