refactor: use Promise.withResolvers() (Node 22+)#503
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Refactors internal async flows to use Promise.withResolvers() instead of new Promise((resolve, reject) => ...), aiming for cleaner promise wiring while keeping behavior consistent on Node 22+.
Changes:
- Refactor
sh()exec wrapper to usePromise.withResolvers()for completion signaling. - Refactor
BackgroundTaskQueueworker message listeners and module registration to usePromise.withResolvers().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| utils/sh.ts | Replaces manual Promise constructor with Promise.withResolvers() around child process lifecycle. |
| utils/background-task-queue.ts | Replaces Promise constructor usages in worker response handling and init registration with Promise.withResolvers(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9df2706 to
889eecb
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replace new Promise((resolve, reject) => { ... }) with the cleaner
Promise.withResolvers() pattern in background-task-queue.ts (2 sites)
and sh.ts (1 site).
889eecb to
87d7f76
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot Can you fix and resolve unaddressed comments and get this happy again? |
…e.ts - sh.ts: Remove broken duplicate Promise.withResolvers + new Promise code; use Promise.withResolvers() properly; switch exit->close for complete stdio flush; add error event handler for spawn failures; make rejection shapes consistent (both reject with Error instances with command/stdout/stderr/code fields) - background-task-queue: Store split2 stream refs so off() targets the right stream and unpipe on cleanup; add worker error/exit handling in run() to prevent deadlocks on unexpected worker failures; add worker error/exit handling in activate() to prevent indefinite hangs during initialization Agent-Logs-Url: https://github.com/speced/respec-web-services/sessions/4640ebb0-d6ac-4269-b7bf-e563038f39e1
Fixed in eef7301. Here's what was addressed:
|
|
@copilot can you review this and fix any issues that come up? |
|
@copilot can you review this again and fix any issues |
|
@copilot Can you confirm that all your comments have been addressed? Please resolve them if you’re happy. Can you fix anything outstanding from your feedback that hasn’t been addressed? |
All reviewer comments have been addressed. Here's the final status:
CI tests are passing on the latest commit (a3bd437). |
* refactor: use Promise.withResolvers() (Node 22+)
Replace new Promise((resolve, reject) => { ... }) with the cleaner
Promise.withResolvers() pattern in background-task-queue.ts (2 sites)
and sh.ts (1 site).
* Apply suggestion from @Copilot
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* fix: address all PR review feedback on sh.ts and background-task-queue.ts
- sh.ts: Remove broken duplicate Promise.withResolvers + new Promise code; use
Promise.withResolvers() properly; switch exit->close for complete stdio flush;
add error event handler for spawn failures; make rejection shapes consistent
(both reject with Error instances with command/stdout/stderr/code fields)
- background-task-queue: Store split2 stream refs so off() targets the right
stream and unpipe on cleanup; add worker error/exit handling in run() to
prevent deadlocks on unexpected worker failures; add worker error/exit
handling in activate() to prevent indefinite hangs during initialization
Agent-Logs-Url: https://github.com/speced/respec-web-services/sessions/4640ebb0-d6ac-4269-b7bf-e563038f39e1
* fix: add job ID to worker unexpected-exit error message for easier debugging
Agent-Logs-Url: https://github.com/speced/respec-web-services/sessions/4640ebb0-d6ac-4269-b7bf-e563038f39e1
* fix: cross-remove error/exit listeners in run() to prevent double lock release
Agent-Logs-Url: https://github.com/speced/respec-web-services/sessions/5a7c6559-a65f-44e5-865b-b8a2f0b8c955
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Summary
Replace
new Promise((resolve, reject) => { ... })withPromise.withResolvers()in 3 call sites:utils/background-task-queue.ts— worker message listener and module registrationutils/sh.ts— shell exec wrapperCleaner code, same behavior. Node 22+ native API.