Skip to content

refactor: replace async.queue with a shared helper - #287

Merged
rvagg merged 3 commits into
nodejs:mainfrom
trivikr:async-queue
Nov 2, 2026
Merged

rvagg merged 3 commits into
nodejs:mainfrom
trivikr:async-queue

Conversation

@trivikr

@trivikr trivikr commented Nov 2, 2026

Copy link
Copy Markdown
Member

Replaces the two near-identical async.queue blocks in collect-commit-labels.js and find-matching-prs.js with a small forEachConcurrent helper, and removes the async dependency. The concurrency limit stays at 15.

Also drops a broken next() call in find-matching-prs.js. next was always undefined there, and the queue swallowed the resulting error, so results weren't affected.

Add forEachConcurrent and use it in collect-commit-labels and
find-matching-prs, then remove the async dependency.
Comment thread for-each-concurrent.js Resolved
Comment thread collect-commit-labels.js Outdated

q.push(sublist)
await q.drain()
return cache[key].then((val) => onFetch(null, val), (err) => onFetch(err))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as long as you're making it fully async, make the callback (onFetch) go away, this just needs a try/catch around await cache[key]:

      try {
        const issue = await cache[key]
        if (issue.labels) {
          commit.labels = issue.labels.map((label) => label.name)
        }
      } catch (err) {
        console.error('Error fetching issue #%s: %s', commit.ghIssue, err.message)
      }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 4d62b27

The worker is now async and awaits cache[key] in a try/catch, and onFetch is gone.

One small behavior change: an error while reading labels (e.g. issue resolving to undefined) is now logged and skipped like a fetch error. On main it's an unhandled rejection that crashes the process.

@rvagg
rvagg merged commit 9736ef6 into nodejs:main Nov 2, 2026
5 checks passed
@trivikr
trivikr deleted the async-queue branch November 2, 2026 07:59
github-actions Bot pushed a commit that referenced this pull request Nov 3, 2026
## [5.1.0](v5.0.14...v5.1.0) (2026-11-03)

### Features

* add `sequence` format ([#249](#249)) ([3f5defd](3f5defd))

### Code Refactoring

* remove redundant 'use strict' from ES modules ([#288](#288)) ([7487189](7487189))
* replace async.queue with a shared helper ([#287](#287)) ([9736ef6](9736ef6))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants