Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BulkNil and execArrayReply breaking xread #333

Open
zifeo opened this issue Sep 22, 2022 · 0 comments
Open

BulkNil and execArrayReply breaking xread #333

zifeo opened this issue Sep 22, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@zifeo
Copy link
Contributor

zifeo commented Sep 22, 2022

Currently execArrayReply casts its return to Array<T> but because of the change with BulkNil the function does not always return an array but also null. This breaks at least xread when the command return nothing (and likely also xreadgroup).

Example:

import { connect } from "https://deno.land/x/[email protected]/mod.ts";

const conf = { hostname: "localhost", port: 6379, password: "password", db: 0 };
const r1 = await connect(conf);
const r2 = await connect(conf);

const key = "topic";

(async () => {
  let cursor = "$";
  while (true) {
    try {
      const [stream] = await r1.xread(
        [{ key, xid: cursor }],
        {
          block: 5000,
        },
      );
      if (!stream) {
        continue;
      }
      for (const { xid, fieldValues } of stream.messages) {
        console.log(fieldValues);
        cursor = xid;
      }
    } catch (error) {
      console.error(error);
    }
  }
})();

(async () => {
  let c = 0;
  while (true) {
    try {
      await r2.xadd(
        key,
        "*",
        { c },
        { approx: true, elements: 10 },
      );
      c += 1;
      await new Promise((resolve) => setTimeout(resolve, 6000));
    } catch (error) {
      console.error(error);
    }
  }
})();

Produces:

TypeError: raw is not iterable
    at parseXReadReply (https://deno.land/x/[email protected]/stream.ts:255:31)
    at https://deno.land/x/[email protected]/redis.ts:1908:21
    at async file:///Users/teostocco/Documents/metatype/metatype/repro.ts:13:24
@uki00a uki00a added the bug Something isn't working label Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants