fix: await issue comment side effects - #103
Open
thc1006 wants to merge 1 commit into
Open
Conversation
thc1006
force-pushed
the
fix/await-issue-comment-side-effects
branch
2 times, most recently
from
August 25, 2026 16:56
88d6a5c to
0eae847
Compare
thc1006
force-pushed
the
fix/await-issue-comment-side-effects
branch
from
August 25, 2026 23:56
0eae847 to
2a8e6ce
Compare
Several command handlers started a label or comment write without awaiting it, so the handler resolved before the write settled and a failed write escaped the hub error handling as an unhandled rejection, never reaching core.setFailed. Await the writes in area, kind, priority, hold, lgtm, and approve, and await the dispatch in main. Also coerce non-Error rejections into Errors so they still fail the Action. Adds regression coverage: a delayed write keeps the handler pending, a failed write reaches setFailed, the module dispatch awaits its handler, and a failed authorization reply still surfaces the original error. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
thc1006
force-pushed
the
fix/await-issue-comment-side-effects
branch
from
August 26, 2026 16:36
2a8e6ce to
34d4142
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.
Description
Several command handlers start a label or comment write and then return without awaiting it.
handleIssueCommentdoesawait area(context), butarearesolves as soon as its synchronous body finishes, before the write it started has settled. A failed write then rejects after the handler already resolved, so the hub's existing.catchnever sees it and the rejection escapes unhandled. The Action does not fail throughcore.setFailed, and on current Node an unhandled rejection terminates the worker.This awaits the writes in
area,kind,priority,hold,lgtm, andapprove(including the two paths that comment when a user is not authorized), and awaits the dispatch so a rejection reachescore.setFailed. It also normalizes non-Error rejections from the issue-comment command handlers, while the top-level dispatcher reports any non-Error handler rejection throughcore.setFailed. Command concurrency and semantics are unchanged; the calls just wait for their own results. The entrypoint is split sorun()lives insrc/run.tsandsrc/main.tsonly invokes it, which lets the dispatch be unit-tested without a module-load side effect.Fixes #102
Why the existing tests did not catch it
The label tests
await handleIssueComment(...)and thenawait observeReq.called(), which proves the request was eventually made but not that the handler waited for it. The added tests close that. One holds the label write open behind a gate and asserts the handler stays pending until it settles. Another makes the write return 500 and assertscore.setFailedis called with the write error. A module-level test drivesrun()with a mocked handler to provesrc/run.tsawaits the dispatch, and anlgtmtest proves that when the unauthorized reply itself fails the Action still surfaces the authorization error. Each of these fails when its await is removed.Scope
No dependencies, parser changes, label behavior, or command ordering were touched.
dist/index.jsis regenerated withnpm run pack, which also brings the bundled transitivebrace-expansionin sync with the unchanged lockfile (the committed bundle was stale); no dependency versions changed.Testing
npm run allpasses (build, lint, pack, test): 84 passing, 6 skippedarea: the handler stays pending until the write settles, and a failed write reachescore.setFailedwith the write errorrun:src/run.tsawaits the dispatched handler and surfaces its rejectionlgtm: a failed unauthorized reply still fails with the authorization errorChecklist:
npm run allto lint and build my code