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

Typescript woes with Pipeline #1584

Closed
pvogel1967 opened this issue May 20, 2022 · 3 comments · Fixed by #1585
Closed

Typescript woes with Pipeline #1584

pvogel1967 opened this issue May 20, 2022 · 3 comments · Fixed by #1585

Comments

@pvogel1967
Copy link

ioredis 4, the "Redis.Pipeline" type had a "length" parameter, so I could do things like this:

    async executePipeline(pipeline: Redis.Pipeline): Promise<[Error | null, any][]> {
        if (pipeline.length < 1) {
            this.logger.warn('Got zero length pipeline to execute');
        }
        const t0 = performance.now();
        const res = await pipeline.exec();
        const t1 = performance.now();
        Math.random() < 0.1 && this.logger.info({ timeTaken: t1 - t0, length: pipeline.length }, `Executed cache pipeline`);
        return res;
    }

In ioredis 5 there doesn't seem to be a way to check the length of the pipeline? This is a problem because I have several places where I'm doing a bunch of work in a loop, pumping it into a pipeline and when the length hits a threshold doing an await pipeline.exec(), then creating a fresh pipeline and the loop continues...

@luin
Copy link
Collaborator

luin commented May 21, 2022

Hey @pvogel1967 👋

The length parameter still exists on v5 and it's an overlook that we don't provide a declaration for it. You can use it with // @ts-expect-error to suppress the warning and we will add the missing declarations in the next version.

@luin luin added the typing label May 21, 2022
luin added a commit that referenced this issue May 21, 2022
luin added a commit that referenced this issue May 21, 2022
luin added a commit that referenced this issue May 21, 2022
@pvogel1967
Copy link
Author

Thanks @luin!

luin added a commit that referenced this issue May 31, 2022
github-actions bot pushed a commit that referenced this issue May 31, 2022
## [5.0.6](v5.0.5...v5.0.6) (2022-05-31)

### Bug Fixes

* Add back Pipeline#length ([#1585](#1585)) ([63b2ee4](63b2ee4)), closes [#1584](#1584)
@github-actions
Copy link

🎉 This issue has been resolved in version 5.0.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

janus-dev87 added a commit to janus-dev87/ioredis-work that referenced this issue Mar 1, 2024
## [5.0.6](redis/ioredis@v5.0.5...v5.0.6) (2022-05-31)

### Bug Fixes

* Add back Pipeline#length ([#1585](redis/ioredis#1585)) ([63b2ee4](redis/ioredis@63b2ee4)), closes [#1584](redis/ioredis#1584)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants