Skip to content

Image (Error: while downloading) #166

@franckdsf

Description

@franckdsf

Hey,
I OFTEN have the following error when adding an image to my prompts :

export const unauthed = mutation({
  args: {
    threadId: v.string(),
    prompt: v.string(),
    imageUrls: v.array(v.string())
  },
  handler: async (ctx, { threadId, prompt, imageUrls }) => {
    // Build the message content with text and images
    const content = [
      ...imageUrls.map((url) => ({
        type: "image",
        image: serializeDataOrUrl(url),
        mediaType: "image/png",
      }) as const),
      { type: "text", text: prompt } as const
    ];

    const { messageId } = await saveMessage(ctx, components.agent, {
      threadId, message: { role: "user", content },
    });

// [...]

    await ctx.scheduler.runAfter(0, internal.llm.messages.images._internal, {
      promptMessageId: messageId,
      threadId,
    });
}
});
export const _internal = internalAction({
  args: { threadId: v.string(), promptMessageId: v.string() },
  handler: async (ctx, { threadId, promptMessageId }) => {
    const { thread } = await basicAgent.continueThread(ctx, { threadId });
    await thread.streamText({ promptMessageId }, { saveStreamDeltas: { chunking: "line", throttleMs: 1000 } });
  },
});

I tried different urls pointing to different domains (including my private CDN), and sometimes it works sometimes it doesn't. I have no clue why..

I feel like I'm parsing the url good with the right format (since sometimes it works).

What's going on ? :)

06/10/2025 23:10:37 [CONVEX M(messages:finalizeMessage)] [ERROR] 'Error in stream' [Error: Timeout while downloading https://s3.eu-central-003.backblazeb2.com/path/to/file/xxxxxx.webp.]   
06/10/2025 23:10:37 [CONVEX M(messages:finalizeMessage)] Uncaught Error: Timeout while downloading https://s3.eu-central-003.backblazeb2.com/path/to/file/xxxxxx.webp.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions