[KongchangAI]
· 1 min read· 977 words

@ai-sdk/vue 4.0.138 Released: Two Major useObject Fixes

@ai-sdk/vue 4.0.138 Released: Two Major useObject Fixes

@ai-sdk/vue 4.0.138 fixes useObject cancellation timing and Headers instance parameter loss.

@ai-sdk/vue 4.0.138 is a patch release with no new features, focusing on fixing two practical issues with the useObject composable in the Vue adapter package. First, when a submission is stopped before the request is actually sent, the cancellation logic fails to take effect, potentially causing users to believe they've cancelled while the request is still sent; after the fix, such submissions are properly cancelled. Second, when developers pass request headers as a standard Headers instance rather than a plain object, authentication or custom headers are silently discarded; after the fix, both forms are correctly passed through. Additionally, the version synchronously upgrades underlying dependencies including [email protected] and @ai-sdk/[email protected], keeping sub-package versions aligned. The article recommends upgrading for projects using useObject for streaming object generation, especially scenarios involving early cancellation or Headers instances.

Vercel's AI SDK Vue adapter package @ai-sdk/vue has released version 4.0.138. This is a typical patch release that introduces no new features, instead focusing on fixing two practical issues in the useObject composable. For developers building streaming AI interaction interfaces with Vue, these two fixes directly affect whether requests can be properly cancelled and whether custom request headers can be successfully passed through.

rss source: @ai-sdk/vue@4.0.138

Two Key Fixes in useObject

Fix One: Cancellation Before Request Starts Now Works

The first issue (commit 7ff6a15) addresses the cancellation timing of useObject submissions. The original description reads "cancel useObject submissions stopped before their request starts," meaning that when a submission is stopped before the request is actually sent, the cancellation logic doesn't take effect properly.

The typical scenario for this type of issue involves rapid user actions: clicking generate and then immediately aborting, or a component unmounting before the request is sent. When cancellation isn't handled correctly, the request may still be sent—the user believes they've cancelled, but resources are still being consumed in the background. After the fix, these "stopped before request starts" submissions are properly cancelled, matching user expectations.

Fix Two: Headers Instance Request Headers No Longer Lost

The second issue (commit 1b5fd20) is about "preserve headers supplied as a Headers instance in useObject requests," meaning that when developers pass a standard Headers instance (rather than a plain object), these request headers are lost in useObject requests.

Headers instances and plain objects are both common parameter forms in JavaScript, but they're handled differently. If the SDK internally only reads headers as an object, the authentication info, tracking identifiers, and other content carried by a Headers instance are silently discarded. After the fix, both forms are correctly preserved and passed through to the request.

useObject is the composable that AI SDK provides for Vue, used to consume streaming structured objects returned by the model within components. Unlike a regular one-shot await call, it maintains a continuous streaming response channel internally and exposes reactive state like loading, object, and error throughout the component lifecycle. Because it runs continuously across multiple frames, the request's "start—in progress—end" phases interleave with component mounting, unmounting, and user interactions—which is exactly why edge cases like cancellation timing and parameter form are particularly prone to issues.

The core philosophy of Vue's Composition API is to encapsulate stateful logic into reusable functions, called within setup or <script setup>. Composables typically register cleanup logic via onScopeDispose or onUnmounted, so when a component unmounts early, whether internally initiated requests can be properly aborted depends directly on whether the implementation handles cancellation at this stage. This explains why "cancellation before the request starts" becomes a typical class of defect.

Headers is a standard interface provided by the Fetch API for representing HTTP request/response headers. Unlike plain JavaScript objects, it stores key-value pairs in a normalized way internally (keys are lowercased, duplicates are merged) and is accessed via methods like get, set, append, has, rather than property reads. Therefore, if code traverses it using Object.keys(headers) or headers[key], the result is often empty or incorrect.

This difference frequently causes "silent loss" when passing headers across libraries: the caller passes a Headers instance according to the standard API, but the callee parses it as a plain object—neither throwing an error nor issuing a warning, ultimately causing the request to fail or behave abnormally due to missing authentication or tracking headers. The robust approach is to check the type first, normalize via new Headers(input) when necessary, then read each entry individually—supporting both object literals and Headers instances.

Synchronized Dependency Upgrades

As a patch release, 4.0.138 synchronously updates a batch of underlying dependencies. The original text lists several dependency update records, explicitly mentioning [email protected] and @ai-sdk/[email protected].

This kind of dependency linkage is standard practice for synchronized releases across AI SDK sub-packages. For consumers, it means the Vue adapter layer maintains version alignment with the core ai package and provider utility packages, typically requiring no separate compatibility handling.

What Developers Should Do

If you're using useObject in your project to implement streaming object generation, upgrading to this version is recommended, especially in the following two situations:

  1. Your interface allows users to cancel operations before generation begins, and you've observed that cancellation doesn't take effect or requests are still sent;
  2. You use Headers instances rather than plain objects in request configuration to pass authentication or custom headers.

Both fixes fall into the category of "no error without upgrading, but behavior doesn't match expectations"—troubleshooting them often requires significant debugging effort. Patch version upgrades carry low risk, so simply update.

Summary

@ai-sdk/vue 4.0.138 is a pragmatic minor release: both fixes target edge cases of useObject in real interaction scenarios—cancellation timing in the request lifecycle and compatibility with request header parameter forms. Combined with synchronized underlying dependency updates, it makes Vue-side AI streaming interactions more reliable. For projects relying on this composable, this is a worthwhile upgrade.

One-line Summary

@ai-sdk/vue 4.0.138 fixes useObject's cancellation timing and Headers instance parameter loss issues.

Paragraph Summary

@ai-sdk/vue 4.0.138 is a patch release with no new features, focusing on fixing two practical issues with the useObject composable in the Vue adapter package. First, when a submission is stopped before the request is actually sent, the cancellation logic fails to take effect, potentially causing users to believe they've cancelled while the request is still sent; after the fix, such submissions are properly cancelled. Second, when developers pass request headers as a standard Headers instance rather than a plain object, authentication or custom headers are silently discarded; after the fix, both forms are correctly passed through. Additionally, the version synchronously upgrades underlying dependencies including [email protected] and @ai-sdk/[email protected], keeping sub-package versions aligned. The article recommends upgrading for projects using useObject for streaming object generation, especially scenarios involving early cancellation or Headers instances—a low-risk, worthwhile patch update.

#@ai-sdk/vue#useObject#AI SDK#Vue composable#patch release#Headers instance#streaming AI
Share:

Related articles