nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

Requests fail with the "Interrupted by user." error

Open yurivict opened this issue 1 year ago • 3 comments

Image

The error repeats when the request is repeated.

Version: 1.17.2 Request: Write a Hello World program in Rust. Provider: ollama2, Model: qwen3-coder OS: FreeBSD 15 STABLE

yurivict avatar Nov 28 '25 08:11 yurivict

Thanks for this. Will take a look 👍

will-lamerton avatar Nov 28 '25 12:11 will-lamerton

Hey @yurivict - we have since pushed a couple of large updates that change the way Nanocoder under the hood works So this may well be fixed.

Are you able to firstly, update to v1.19.0 and try again. If the problem still persists, I'd @Avtrkrb to jump in here and tell you how to get us logs :)

will-lamerton avatar Dec 16 '25 10:12 will-lamerton

Root Cause Analysis

Status: Issue confirmed still valid after code review.

Location: source/ai-sdk-client/chat/chat-handler.ts (lines 255-264)

The Bug

// Line 230-237: Correctly handles actual user cancellation
if (error instanceof Error && error.name === 'AbortError') {
    throw new Error('Operation was cancelled');  // ✓ Correct
}

// Line 255-264: Incorrectly assumes NoOutputGeneratedError = cancellation
if (error.name === 'AI_NoOutputGeneratedError' || 
    error.message.includes('No output generated')) {
    const rootError = extractRootError(error);
    if (rootError === error) {
        // BUG: Assumes empty response = user cancelled
        throw new Error('Operation was cancelled');  // ✗ Wrong
    }
}

Why This Happens

  1. Real user cancellation throws AbortError → handled correctly at line 230
  2. When model returns empty response, AI SDK throws AI_NoOutputGeneratedError
  3. Since there's no nested API error, line 262-264 falsely reports "Interrupted by user"

This explains the FreeBSD + Ollama + qwen3-coder behavior - the model likely returns empty responses for certain prompts.

Proposed Fix

Check signal?.aborted before treating as cancellation:

if (rootError === error) {
    if (signal?.aborted) {
        throw new Error('Operation was cancelled');
    }
    // Model returned empty - NOT a user cancellation
    throw new Error('Model returned empty response. Try again or use a different model.');
}

Confidence: High

JimStenstrom avatar Dec 26 '25 05:12 JimStenstrom