fix: make sure cancel actually aborts push#1831
Conversation
08abd30 to
f8c2d77
Compare
14f10f4 to
61fd2b6
Compare
|
| const onAbort = () => { | ||
| if (!this.#pendingRequests.has(scopedId)) return; | ||
| this.#electronTRPC.sendMessage({ | ||
| id: scopedId, | ||
| method: "operation.cancel", | ||
| }); | ||
| }; |
There was a problem hiding this comment.
Aborted operation may wait forever if cancel races context creation
operations.set only happens after await createContext() returns (line 52 → 71 in handleIPCMessage.ts). If the AbortSignal fires and operation.cancel is dispatched during that await, operations.get(internalId) returns undefined and the abort is silently dropped. The renderer then waits indefinitely for a response that will never arrive, because the procedure itself runs to completion uninterrupted.
A small hardening in handleIPCMessage.ts would close it: move operations.set(internalId, abortController) to immediately before await createContext(), or check abortController.signal.aborted right after createContext returns.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/electron-trpc/src/renderer/ipcLink.ts
Line: 96-102
Comment:
**Aborted operation may wait forever if cancel races context creation**
`operations.set` only happens after `await createContext()` returns (line 52 → 71 in `handleIPCMessage.ts`). If the `AbortSignal` fires and `operation.cancel` is dispatched during that `await`, `operations.get(internalId)` returns `undefined` and the abort is silently dropped. The renderer then waits indefinitely for a response that will never arrive, because the procedure itself runs to completion uninterrupted.
A small hardening in `handleIPCMessage.ts` would close it: move `operations.set(internalId, abortController)` to immediately before `await createContext()`, or check `abortController.signal.aborted` right after `createContext` returns.
How can I resolve this? If you propose a fix, please make it concise.|
|
||
| modal.setPushState("success"); | ||
| } catch (error) { | ||
| if (controller.signal.aborted) { | ||
| trackGitAction(taskId, store.pushMode, false); | ||
| return; | ||
| } | ||
| log.error("Push failed", error); | ||
| const message = error instanceof Error ? error.message : "Push failed."; | ||
| trackGitAction(taskId, store.pushMode, false); | ||
| modal.setPushError(message); | ||
| modal.setPushState("error"); | ||
| } finally { | ||
| if (pushAbortRef.current === controller) { |
There was a problem hiding this comment.
trackGitAction duplicated across both catch branches
trackGitAction(taskId, store.pushMode, false) appears identically in both the aborted path and the error path. Per the OnceAndOnlyOnce principle, it can be hoisted before the branch:
| modal.setPushState("success"); | |
| } catch (error) { | |
| if (controller.signal.aborted) { | |
| trackGitAction(taskId, store.pushMode, false); | |
| return; | |
| } | |
| log.error("Push failed", error); | |
| const message = error instanceof Error ? error.message : "Push failed."; | |
| trackGitAction(taskId, store.pushMode, false); | |
| modal.setPushError(message); | |
| modal.setPushState("error"); | |
| } finally { | |
| if (pushAbortRef.current === controller) { | |
| } catch (error) { | |
| trackGitAction(taskId, store.pushMode, false); | |
| if (controller.signal.aborted) { | |
| return; | |
| } | |
| log.error("Push failed", error); | |
| const message = error instanceof Error ? error.message : "Push failed."; | |
| modal.setPushError(message); | |
| modal.setPushState("error"); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/git-interaction/hooks/useGitInteraction.ts
Line: 463-476
Comment:
**`trackGitAction` duplicated across both catch branches**
`trackGitAction(taskId, store.pushMode, false)` appears identically in both the aborted path and the error path. Per the OnceAndOnlyOnce principle, it can be hoisted before the branch:
```suggestion
} catch (error) {
trackGitAction(taskId, store.pushMode, false);
if (controller.signal.aborted) {
return;
}
log.error("Push failed", error);
const message = error instanceof Error ? error.message : "Push failed.";
modal.setPushError(message);
modal.setPushState("error");
```
How can I resolve this? If you propose a fix, please make it concise.f8c2d77 to
c7b587f
Compare
61fd2b6 to
5bb6709
Compare
c7b587f to
cb07e28
Compare
5bb6709 to
3ddb134
Compare
cb07e28 to
172016f
Compare
3ddb134 to
3c8f815
Compare
172016f to
b5e3a2e
Compare
3c8f815 to
6749f51
Compare
b5e3a2e to
4691a08
Compare
6749f51 to
cbd0c88
Compare
4691a08 to
34161ec
Compare
cbd0c88 to
22fdcea
Compare
cbac191 to
d483201
Compare
22fdcea to
7126725
Compare
d483201 to
247538a
Compare
7126725 to
cd3953a
Compare
cd3953a to
5412863
Compare
Merge activity
|

Now that we immediately push on
push & commitwe should let the user abort the push with the cancel button in the UI. HOWEVER we do not support canceling TRPC procedures viaelectron-trpcso we had to add that in as well.