Add workId to localConcurrency workers and WIP data#764
Open
bcomnes wants to merge 2 commits intotimgit:masterfrom
Open
Add workId to localConcurrency workers and WIP data#764bcomnes wants to merge 2 commits intotimgit:masterfrom
bcomnes wants to merge 2 commits intotimgit:masterfrom
Conversation
There was a problem hiding this comment.
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
workIdtoWorkerinstances and include it intoWipData()output. - Extend public
WipDatatype and API docs to includeworkId. - Add a test asserting that all
wipentries for a localConcurrencywork()share the sameworkId.
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.
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.
ee5fc2d to
a18c48e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.