Support AbortSignal in AI Gateway binding.#6537
Conversation
I had intended to cover this in #6379 but missed it somehow. (Written by GPT 5.4.)
`AbortSignal` does not work over RPC, but people with the "experimental" compat flag are opted into RPC. Gadgets desperately needs AbortSignal support, but uses "experimental". Since there was already a "beta" flag to explicitly opt in, I made it so explicitly setting it `false` opts out, overriding the "experimental" flag.
|
I've reviewed all the changed files and surrounding context. Let me now analyze the changes: Changes summary:
Analysis:
I don't see any actionable issues with this PR. LGTM |
|
By the way, our own ai-gateway-provider package (vercel AI SDK plugin) is already passing this option along when the application passes an AbortSignal to AI SDK... because I asked @threepointone to implement that before I realized the runtime itself didn't support it, and he dutifully did as I asked. As a result, when the binding started using RPC (for "experimental" users) last week, it actually broke anyone using ai-gateway-provider, AbortSignal, and the "experimental" flag together. Which may very well have been only me, but it was a spontaneous breakage in prod, which confused me. |
G4brym
left a comment
There was a problem hiding this comment.
lgtm
i was the one enabling RPC when experimental flag is active last week, sorry about breaking your worker
I had intended to cover this in #6379 but missed it somehow.
(Written by GPT 5.4.)
I also added the ability to opt out of RPC by passing
{beta: false}, because AbortSignal doesn't work over RPC yet, and Gadgets needs this, and Gadgets sets the "experimental" flag so would otherwise get RPC by default.