You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry if I'm missing something obvious but BRPOP does not seem to actually resolve when a queued item becomes available. If something is present when BRPOP is initiated it immediately resolves otherwise it 'blocks' until timeout and resolves with null.
Example:
import { Redis } from 'ioredis';
(async () => {
const redis = new Redis();
setTimeout(() => {
redis.lpush('some-queue', 'a queued thing');
}, 1000);
const start = Date.now();
do {
const queuedThing = await redis.brpop('some-queue', 10);
if (!queuedThing) {
console.log('Timeout waiting for queue, elapsed:', Date.now() - start);
continue;
}
console.log('Got thing from queue:', queuedThing, 'elapsed:', Date.now() - start);
process.exit(0);
} while (true);
})();
Output:
ts-node example.ts
Timeout waiting for queue, elapsed: 10041
Got thing from queue: [ 'some-queue', 'a queued thing' ] elapsed: 10043
A timeout should not occur right? The loop should block for 1 second and then process the LPUSHed event and then exit.
redis-server 7.4.1
ioredis 5.4.1
node 20.15.1
edit-- I tested directly w/ redis-cli and it works as expected.
The text was updated successfully, but these errors were encountered:
import{Redis}from'ioredis';(async()=>{constproducer=newRedis();constconsumer=newRedis();setTimeout(()=>{producer.lpush('some-queue','a queued thing');},1000);conststart=Date.now();do{constqueuedThing=awaitconsumer.brpop('some-queue',10);if(!queuedThing){console.log('Timeout waiting for queue, elapsed:',Date.now()-start);continue;}console.log('Got thing from queue:',queuedThing,'elapsed:',Date.now()-start);process.exit(0);}while(true);})();
Hi,
Sorry if I'm missing something obvious but BRPOP does not seem to actually resolve when a queued item becomes available. If something is present when BRPOP is initiated it immediately resolves otherwise it 'blocks' until timeout and resolves with null.
Example:
Output:
A timeout should not occur right? The loop should block for 1 second and then process the LPUSHed event and then exit.
redis-server 7.4.1
ioredis 5.4.1
node 20.15.1
edit-- I tested directly w/ redis-cli and it works as expected.
The text was updated successfully, but these errors were encountered: