caolan / caolan/highland

Pausing a rate-limited stream doesn't work

Open
#642 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
3.4k
Forks
145
PR merge metrics
No merged PRs in 30d

Description

Hi,

I've been trying the following code:

```js
const highland = require('highland');
const { Writable } = require('stream');

const writable = new Writable({
objectMode: true,
write(chunk, encoding, callback) {
console.log('=>', chunk.toString());
callback();
},
});

const stream = highland(['a', 'b', 'c', 'd']).ratelimit(1, 1000);

setTimeout(() => {
console.log('Pausing...');
stream.pause();
}, 2000);
setTimeout(() => {
console.log('Resuming...');
stream.resume();
}, 6000);
stream.pipe(writable);
```

But what I've found is that a rate-limited stream doesn't pause. Is it an expected behavior?

Thanks!

Contributor guide

Open the contributing guide

Research direction

Reproduce the JavaScript example using Highland's ratelimit stream and its pause/resume entry points, observing emissions before and after the timers. Read the ratelimit implementation and related stream tests; done means the pause behavior is either confirmed and documented or corrected with a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.