Conversation
OneCLI shared one ApprovalClient across calls. stop() only clears the shared running flag, so calling configureManualApproval again right after stop() set it back before the stopped loop checked it. That loop backed off, kept polling, and passed approvals to the stopped handle's callback. Create a client per call, as org.configureManualApproval already does.
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.
What is the current behavior?
OneCLIcreates oneApprovalClientin its constructor, and everyconfigureManualApprovalcall starts that same instance.stop()sets the sharedrunningflag tofalseand aborts the current poll.If you stop a handle and then call
configureManualApprovalagain, for example to swap the callback, the newstart()setsrunningback totruesynchronously, before the stopped loop has seen the aborted poll. When the stopped loop gets to itscatch,if (!this.running) returnis false, so it backs off for 5s and keeps polling. After that, both loops take pending approvals, and the stopped handle's callback keeps deciding some of them. In the test below, it denies a request that the new callback would have approved.The stopped loop also overwrites the shared
abortController, so a laterstop()aborts only one of the two polls.What is the new behavior?
Each
configureManualApprovalcall gets its ownApprovalClient, and the handle stops that client.org.configureManualApprovalalready works this way. A stopped handle stays stopped, whatever other calls do afterwards.This is independent of #58, which moves the gateway URL resolution into the poll loop. The two PRs touch different files.
Additional context
test/approvals/configure.test.tsregisters a callback, stops it, registers a second one, and then answers every poll that is still open with one pending request. It checks that only the second callback receives the request.Checked locally on Node 22 with pnpm 10.30.1:
main(6579233)ap-1pnpm testpnpm typecheckpnpm buildNot tested against a running OneCLI instance.