wrong release function in async example
Open
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- backend
Research direction
Find the async example containing the release(item) function and inspect how queued requests receive released items. Verify the queue handoff and free/available accounting, then exercise the example's release behavior to confirm that an item handed directly to a queued user is not also counted as free.
Written by the indexing model from the issue text.
Description
release(item) {
const index = this.items.indexOf(item);
if (index < 0) throw new Error('Pool: release unexpected item');
if (this.free[index]) throw new Error('Pool: release not captured');
this.free[index] = true;
this.available++;
if (this.queue.length > 0) {
const { resolve, timer } = this.queue.shift();
clearTimeout(timer);
if (resolve) setTimeout(resolve, 0, item);
}
}
error - we should not free released item if we resolve it for user in queue
release(item) {
const index = this.items.indexOf(item);
if (index < 0) throw new Error('Pool: release unexpected item');
if (this.free[index]) throw new Error('Pool: release not captured');
if (this.queue.length > 0) {
const { resolve, timer } = this.queue.shift();
clearTimeout(timer);
if (resolve) setTimeout(resolve, 0, item);
} else {
this.free[index] = true;
this.available++;
}
}
- Dominant language
- JavaScript
- Stars
- 8
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.