Skip to content

Commit a5f4192

Browse files
easonLiangWorldedtecheasonliang28edelauna
authored
feat(api): abort signal support for bedrock (completePrompt + createMessage) (#1292)
* feat(api): add abort signal support for bedrock (completePrompt + createMessage) Wires external abort signals into the AWS Bedrock provider on both request paths. - completePrompt: merge options.abortSignal and options.timeoutMs via mergeAbortSignalAndTimeout (merged utils API, no cleanup) and forward the resulting signal as client.send abortSignal; sendOptions is undefined when no signal/timeout applies. - createMessage: bridge metadata?.abortSignal into the existing internal AbortController (pre-aborted guard + { once: true } listener), preserving the existing 10-minute request timeout. Tests: ports the reference spec additions (abort/timeout propagation to client.send, backward compatibility, empty response handling) and adds createMessage abort coverage (pre-aborted signal and mid-stream abort both reject with an error whose name === "AbortError"). * fix(api): address CodeRabbit review on bedrock createMessage abort lifecycle The external abort bridge listener was only removed when the signal actually aborted; a completed request left the listener (and its closure over the request controller) attached to the caller's signal. Make the controller request-local and detach the listener in a finally block so the external signal keeps no reference after the request ends (success or error). Test: createMessage regression - first request completes normally, a second request starts with a different external signal; the first signal's listener is removed on completion and aborting it late does not cancel the second stream. * fix(api): clear bedrock createMessage request timeout in finally When a caller stops consuming the generator early (break/destroy), the generator enters the finally block without reaching the stream-completion timeout-clearing path, leaving the 10-minute request timer active and retaining the request controller until it expires. Clear the timeout at the start of the finally block, before the abort-listener removal. Test: createMessage regression - the generator is terminated early mid-stream and the 10-minute timer handle (captured via typed spies on setTimeout/clearTimeout) is asserted to have been cleared. * test(api): close changed-line coverage gaps in bedrock * test(bedrock): strengthen abort signal coverage and add CodeRabbit rules --------- Co-authored-by: Eason Liang <[email protected]> Co-authored-by: Elliott de Launay <[email protected]>
1 parent 104700e commit a5f4192

3 files changed

Lines changed: 709 additions & 5 deletions

File tree

‎.coderabbit.yaml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ reviews:
5858
Check cleanup and deterministic async behavior and prefer shared typed test helpers.
5959
Visible webview changes require a durable Playwright component snapshot; behavior-only
6060
changes do not.
61+
Reject weak assertions on values that could take multiple forms: .toBeDefined() or
62+
.toHaveBeenCalled() alone are not sufficient when the actual type, value, or object
63+
identity is verifiable. For listener registration and removal, assert the same function
64+
reference was added and removed (not expect.any(Function)).
65+
Flag tests that assert in-flight behavior only after the call completes — these cannot
66+
prove the behavior fires during execution. Check that describe block names match the
67+
actual subjects of the tests they contain.
6168
6269
- path: "apps/vscode-e2e/**"
6370
instructions: >-

0 commit comments

Comments
 (0)