Skip to content

Add workId to localConcurrency workers and WIP data#764

Open
bcomnes wants to merge 2 commits intotimgit:masterfrom
bcomnes:corelate-wip-to-worker
Open

Add workId to localConcurrency workers and WIP data#764
bcomnes wants to merge 2 commits intotimgit:masterfrom
bcomnes:corelate-wip-to-worker

Conversation

@bcomnes
Copy link
Copy Markdown
Contributor

@bcomnes bcomnes commented Apr 10, 2026

When creating workers with localConcurrency, it can be challenging to differentiate what worker came from what work call when picking through WIP data. This PR adds a workId to workers that is also exposed in WIP data. When processing WIP data for metrics and whatnot, you can use the workId to correlate the metrics to the input settings that made the worker.

Copilot AI review requested due to automatic review settings April 10, 2026 04:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a workId identifier to each localConcurrency worker and exposes it via the wip event payload so callers can correlate WIP metrics back to a specific work() invocation.

Changes:

  • Add workId to Worker instances and include it in toWipData() output.
  • Extend public WipData type and API docs to include workId.
  • Add a test asserting that all wip entries for a localConcurrency work() share the same workId.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/workTest.ts Adds coverage validating wip correlation via workId for localConcurrency workers.
src/worker.ts Stores workId on workers and includes it in toWipData().
src/types.ts Extends WipData with workId in the public type surface.
src/manager.ts Plumbs the workId (returned by work()) into all spawned localConcurrency workers.
docs/api/events.md Documents workId in wip payload and provides correlation example usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 10, 2026

Coverage Status

coverage: 100.0%. remained the same — bcomnes:corelate-wip-to-worker into timgit:master

fix: increase handler delay so wip event fires in workId correlation test

The wip event is rate-limited to once per 2s and only fires when
onFetch processes jobs. With delay(50) the job completes before 2s
elapses from manager creation, so emitWip never fires and the test
times out. Increase to delay(3000) so the end-of-onFetch emitWip
call happens after the 2s threshold.

Also resolve handlerCompleted before the delay so it doesn't
block the wip assertions.
@bcomnes bcomnes force-pushed the corelate-wip-to-worker branch from ee5fc2d to a18c48e Compare April 10, 2026 05:10
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.

3 participants