Git Product home page Git Product logo

async-redis's Introduction

async-redis's People

Contributors

andylash avatar bikov avatar cpeddecord avatar cryptiklemur avatar dcstone09 avatar dependabot[bot] avatar jakesylvestre avatar jd20 avatar moaxaca avatar protongustave avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

async-redis's Issues

Simple instance error

const client = require('async-redis').createClient('6379', '127.0.0.1');
const logger = require('tracer').console();

client.on("error", err => logger.log(err));

(async () => {
    await client.set("string key", "stringvalue");
    const value = await client.get("string key");
    logger.log(value);
    await client.flushall("string key");
})();

show result:

(node:2828) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): ReplyError: ERR wrong number of arguments for 'flushall' command
(node:2828) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I'm a beginner,I want answers,thanks!

1.1.3+

From version 1.1.3 on using the module with typescript gives an error:

server.ts(13,29): error TS2306: File ./node_modules/async-redis/index.d.ts' is not a module.

Line 13 reads:
import * as asyncRedis from 'async-redis';

version 1.1.2 and below works fine.

Hope this helps.

Regards,
Wessel

Typescript compiler imports index.d.ts instead of index.js

Hi!

Thanks for a great module! ๐Ÿ˜Š

Since version 2.0.0 async-redis is no longer working with typescript. it seems like tsc is loading src/index.d.ts file instead of src/index.js.

Reproducible steps:

  1. create a new project
  2. create index.ts
  3. install async-redis
  4. write this line of code: import { createClient } from 'async-redis';
  5. compile index.ts: tsc index.ts

I am using typescript 4.3.2 version.

publish latest

master is behind the latest npm release. specifically, i'm looking at this: #37

createClient blocks

Both variants do not return to console.

const asyncRedis = require("async-redis");
const client = asyncRedis.createClient();


// (async () => {
//     console.log("hello")
// })()

console.log("hello")

createClient is to blame

decorate without mutating

It would be great if .decorate didn't change the supplied redis object but rather returned a new one.

NOAUTH Authentication required (How to handle passwords?)

My Redis has a password, advised by every quickstart guide:

ReplyError: Ready check failed: NOAUTH Authentication required.

I pretty much expected this -- but I oddly saw no mention of passwords in the README despite being such a general thing: How to simply include the redis password when connecting?

connect-redis conflicts with async-redis

I am using connect-redis as a Redis session store backed by node_redis. Everything is fine if I use a normal redisClient without decorating it by async-redis. However after I decorated redisClient with async-redis, the connect-redis module seem didn't work anymore.

I hope it would be better if decorate function does not change the original redisClient and returning a new object instead

Interrupted watch-ed transaction returns true instead of null

Scenario:

  1. (client 1) Run watch on a key
  2. (client 1) Set timeout of 10 sec for starting multi + modifying the key
  3. (client 2) Modify key
  4. (client 1) Exec the multi

Client 2 returns true, whereas it should return null, since the watched key has been modified from another client.
I tested the same scenario with redis and it works as expected. The problem is that I have to promisify it with Bluebird.

v2 completely broke several connections to single redis

Just abstract example:

(async f1() {
  const client1 = asyncRedis.createClient();
  await client1.blpop("some", 0);
})()

(async f2() {
  const client2 = asyncRedis.createClient();
  await client2.lpush("some", 42); 
})()

f2's lpush will never be called as client1 and client2 share same connection due to new implementation

Build failing

FYI: The current build is failing due to some code coverage checks failing.

Modifiers doesn't work

Hello, I try to do something like:

await client.set('key', 'value', {
  EX: 10
});

But getting err :>> Error: node_redis: The SET command contains a invalid argument type. Only strings, dates and buffers are accepted. Please update your code to use valid argument types.

Connecting to a non-localhost Redis instance

const asyncRedisClient = require("async-redis").createClient(1111, '8.8.8.8');

It looks like the second argument ("8.8.8.8") is being ignored:

Error: Redis connection to 127.0.0.1:1111 failed - connect ECONNREFUSED 127.0.0.1:1111

Edit: Just found this workaround:

const asyncRedisClient = require("async-redis").createClient(`redis://8.8.8.8:1111`);

createClient not work after quit

Node: v12.18.2
redis: 5.0.5 (docker image)
async-redis: 2.0.0

Error occur as " AbortError: BLPOP can't be processed. The connection is already closed. "

This is ample code where an error occurs.

const redis = require('async-redis')

let client = redis.createClient("redis://localhost:6379");

let cnt = 0;

async function reconnect() {
    try {
        await client.quit()
        client = null
        client = redis.createClient("redis://localhost:6379");
        console.log('reconnect');
    } catch (error) {
        console.log(error);
    }
}


(async () => {
    while (true) {
        try {
            
            cnt++

            const v = await client.blpop('*', 1)

            if (cnt%5 === 0) {
                throw Error("Test")
            }
        } catch (error) {
            console.error(error);
            await reconnect()
            
        }
    }
})()

But below code work well.
There seems to be a problem with clients with the same option as they connected before.

is it bug?

const redis = require('async-redis')

let client = redis.createClient("redis://localhost:6379");

let cnt = 0;

async function reconnect() {
    try {
        await client.quit()
        client = null
        client = redis.createClient("redis://localhost:6379", {
            customOption: Date.now(), // Here
        });
        console.log('reconnect');
    } catch (error) {
        console.log(error);
    }
}


(async () => {
    while (true) {
        try {
            
            cnt++

            const v = await client.blpop('*', 1)

            if (cnt%5 === 0) {
                throw Error("Test")
            }
        } catch (error) {
            console.error(error);
            await reconnect()
            
        }
    }
})()

Update redis

Hey ๐Ÿ––,

Could you update redis and redis-command to their latest version?
Because right now, this version of redis require hiredis which is deal breaking for me.

doesnt work with redis-rejson

using this code:

const redis = require("redis"),
  rejson = require("redis-rejson"),
  asyncRedis = require("async-redis");

rejson(redis); /* important - this must come BEFORE creating the client */
let redisClient = redis.createClient();
let asyncRedisClient = asyncRedis.decorate(redisClient);

retrieving any value is fine, like:

myString = await asyncRedisClient.get("myKey1");

but I always get a boolean true value in myJson if

myJson = await asyncRedisClient.json_get("myKey2", ".")

should it work with redis-rejson ?
thanks

client.multi() not working

using the following, for example, does not work
await client.multi().set('a','b').exec()

temporary fix:

  1. in node_modules/redis-commands/commands.json, remove the multi key (or find a way to skip multi in async-redis decorate)
  2. use
const redis = require("redis")
const asyncRedis = require("async-redis")
const client = redis.createClient()
const asyncRedisClient = asyncRedis.decorate(client)
  1. use all commands the normal way, except for multi - wrap it in a promise
const res = await new Promise((resolve, reject)=>{
 multistack = asyncRedisClient.multi()
 multistack.set('a','b')
 multistack.hset('h','x','y')
 multistack.exec((err,results)=>{
  resolve(results)
 })
})

createClient method not always behaving as expected

Hi,

First of all, thanks for this library. It is much appreciated. Good work. :)

I ran into an issue yesterday and I managed to narrow it down to the way the createClient method works within AsyncRedis.

It seems that the method will not create two distinct client instances with the same configuration - as opposed to what the base Redis method implementation would. Instead, it keeps track of created clients and stores them in an internal array, so that a the same instance will be returned when equivalent options are a match.

I'm not sure why it was designed that way. There may be a very valid reason I'm simply unaware of. In any case, this is a problem for situations in which you do need two distinct clients on the same database, such as when one acts as a subscriber and the other as a publisher. You'd be calling createClient method twice on two distinct variables and use them as pub/sub pattern dictates; still, the code would fail at runtime with the following error message:

ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context

The workaround I came up with was to create clients out of base Redis library, then use AsyncRedis.decorate on them. Works like a charm and still allows using promises.

If pooling of client instances really is the intended design for createClient, then I suggest documenting the method accordingly.

Thanks! :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.