New Apr 7, 2026

@google/genai SDK: ai.files.upload ignores abortSignal and doesn't throw any exception when I try to abort

Libraries, Frameworks, etc. All from Newest questions tagged vue.js - Stack Overflow View @google/genai SDK: ai.files.upload ignores abortSignal and doesn't throw any exception when I try to abort on stackoverflow.com

I am using the official @google/genai SDK in a Vue.js application. I am trying to implement a cancellation mechanism for file uploads using an AbortController.

However, when I trigger .abort(), the ai.files.upload method completely ignores the signal. It does not throw any exception, the execution flow completely bypasses the catch block, and the upload resolves successfully. Funny enough, abortController.signal.aborted evaluates to true.

Here's a minimal reproducible example (note that even though the blob is tiny, I can click the abort button fast enough):

<script setup>
import { ref } from 'vue';
import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({ apiKey: "BLABLABLABLABLA" });

const result = ref(""); let abortController;

async function sendRequest() { abortController = new AbortController();

try { console.log("Uploading blob"); const mockAudioBlob = new Blob(["fake audio bytes"], { type: "audio/mp3" }); const myFile = await ai.files.upload({ file: mockAudioBlob, config: { abortSignal: abortController.signal } });

result.value = myFile.uri; console.log(myFile.uri); console.log("Aborted? " + abortController.signal.aborted); } catch (e) { if (e && e.name === "AbortError") { console.log("Request was aborted"); } else { console.log(e); } } finally { abortController = null; } }

function abortRequest() { if (abortController && abortController.signal && !abortController.signal.aborted) { abortController.abort(); } }

</script>

<template>

<button @click="sendRequest">Upload</button> <button @click="abortRequest">Abort</button> <p>{{ result }}</p>

</template>

I would expect that an exception is raised and the code flows into the catch block.

Is this intended or is it a bug in the SDK?

Scroll to top