SillyTavern/SillyTavern · error · Error

BFL failed to generate image.

Error message

BFL failed to generate image.

What it means

Explicit throw: the BFL task status was neither 'Pending' nor 'Ready' (e.g. 'Failed', 'Error', 'Cancelled', or an unrecognised status string). The thrown Error carries statusData as its cause; it propagates to the catch at 1579 which console.errors it and returns a bare 500, discarding the cause for the client.

Source

Thrown at src/endpoints/stable-diffusion.js:1576

                return response.sendStatus(500);
            }

            /** @type {any} */
            const statusData = await statusResult.json();

            if (statusData?.status === 'Pending') {
                continue;
            }

            if (statusData?.status === 'Ready') {
                const { sample } = statusData.result;
                const fetchResult = await fetch(sample);
                const fetchData = await fetchResult.arrayBuffer();
                const image = Buffer.from(fetchData).toString('base64');
                return response.send({ image: image });
            }

            throw new Error('BFL failed to generate image.', { cause: statusData });
        }
    } catch (error) {
        console.error(error);
        return response.sendStatus(500);
    }
});

const falai = express.Router();

falai.post('/models', async (_request, response) => {
    try {
        const modelsUrl = new URL('https://fal.ai/api/models?categories=text-to-image');
        let page = 1;
        /** @type {any} */
        let modelsResponse;
        let models = [];

        do {

View on GitHub (pinned to 8172dcd0ee)

Solutions

  1. Enumerate known failure statuses ('Failed','Error') and return a descriptive 4xx/5xx instead of a generic 500.
  2. Return error.cause (the statusData) to the client like the FAL.AI handler does at line 1725.
  3. Retry on transient failure statuses rather than throwing immediately.

Example fix

// before
            throw new Error('BFL failed to generate image.', { cause: statusData });
        }
    } catch (error) {
        console.error(error);
        return response.sendStatus(500);
    }
// after
            return response.status(502).send({ error: 'BFL failed to generate image.', status: statusData });
        }
    } catch (error) {
        console.error(error);
        return response.status(500).send(error.cause || error.message);
    }
Defensive patterns

Strategy: type-guard

Type guard

/** @param {any} s */
function isBflFailureStatus(s) {
  return typeof s === 'string' && !['Pending', 'Ready'].includes(s);
}

Try / catch

// handle known statuses explicitly instead of throwing into a bare-500 catch
if (!['Pending', 'Ready'].includes(statusData?.status)) {
  console.warn('BFL terminal status', statusData?.status, statusData);
  return response.status(502).send({ error: 'BFL failed to generate image.', status: statusData });
}

Prevention

When it happens

Trigger: BFL content-moderation rejection; task failed server-side (GPU error); status field renamed so neither branch matches; task cancelled.

Common situations: Prompt tripped Flux safety filters; upstream model crash; API version introducing a new status value the code does not enumerate.

Related errors


AI-assisted analysis of SillyTavern/SillyTavern@8172dcd0ee (2026-08-13). Data as JSON: /api/errors/4d82dbc9b95139ba. Report an issue: GitHub.