- 
                Notifications
    
You must be signed in to change notification settings  - Fork 87
 
Open
Description
When repository.createIndex is called multiple times concurrently, it might throw an exception [ErrorReply: Index already exists]. This happens when test runner run app init code concurrently.
Another problem is that the thrown exception should be an Error.
Reproduction:
import { createClient } from "redis";
import { Schema } from "redis-om";
import { Repository } from "redis-om";
async function main() {
  const redis = createClient();
  await redis.connect();
  {
    const schema = new Schema("s", {
      a: { type: "string" },
    });
    const repo = new Repository(schema, redis);
    await repo.createIndex();
  }
  {
    const schema = new Schema("s", {
      a: { type: "string" },
      b: { type: "string" },
    });
    const repo = new Repository(schema, redis);
    await Promise.all([
      repo.createIndex(),
      repo.createIndex(),
      repo.createIndex(),
      repo.createIndex(),
      repo.createIndex(),
    ]);
  }
  return redis.quit();
}
main().catch((err) => {
  console.error("err at main", err);
});Metadata
Metadata
Assignees
Labels
No labels