mudler/LocalAI · warning · RuntimeError
request was cancelled
Error message
request was cancelled
What it means
RuntimeError raised inside the avatar segment loop when context.is_active() reports the gRPC context is no longer active — the client cancelled the call, its deadline expired, or the connection dropped. Because avatar generation is sequential over segments (each ~93 frames with 13 conditioning frames carried over), the loop checks cancellation between segments and aborts instead of burning GPU on a dead request. Unlike the ValueError checks, this is a server-side cancellation signal, not a client input error.
Source
Thrown at backend/python/longcat-video/backend.py:729
**common,
)
else:
width, height = validate_dimensions(request.width, request.height)
output, latent = self.pipeline.generate_at2v(
height=height,
width=width,
**common,
)
video = self._frames_to_pil(output[0])
width, height = video[0].size
current_video = video
reference_latent = latent[:, :, :1].clone()
all_frames = list(video)
for segment in range(1, segments):
if hasattr(context, "is_active") and not context.is_active():
raise RuntimeError("request was cancelled")
print(
f"Generating avatar segment {segment + 1}/{segments}", file=sys.stderr
)
audio_start += segment_frames - conditioning_frames
output, latent = self.pipeline.generate_avc(
video=current_video,
video_latent=latent,
prompt=request.prompt,
negative_prompt=negative_prompt,
height=height,
width=width,
num_frames=segment_frames,
num_cond_frames=conditioning_frames,
num_inference_steps=steps,
text_guidance_scale=text_guidance,
audio_guidance_scale=audio_guidance,
generator=generator,
output_type="both",View on GitHub (pinned to 44413a9d06)
Solutions
- Raise or remove the client-side deadline so it exceeds worst-case total generation time (segments x per-segment time)
- Only cancel when truly intended; if it fires spuriously, keep the gRPC channel alive (heartbeats/keepalive) during long jobs
- Treat this error as benign cleanup on the server; on the client map UNAVAILABLE/CANCELLED to a user-facing 'generation stopped' state
Example fix
# before response = stub.Video gen(timeout=30)) # too short for multi-segment # after response = stub.GenerateVideo(req, timeout=1800) # deadline sized to full job
Defensive patterns
Strategy: try-catch
Validate before calling
# No pre-validation possible (server-observed cancellation), but size the deadline: # estimated segments = ceil((audio_seconds * 25 - 93) / 80) + 1 # deadline > segments * worst_case_seconds_per_segment + slack import math segments = max(1, math.ceil((audio_seconds * 25 - 93) / 80) + 1) timeout = int(segments * 120) + 60
Try / catch
try:
resp = stub.GenerateVideo(req, timeout=timeout)
except grpc.RpcError as e:
if e.code() in (grpc.StatusCode.CANCELLED, grpc.StatusCode.DEADLINE_EXCEEDED):
log.info("generation cancelled/deadline — retry with longer timeout if wanted")
# safe to retry: generation is stateless per request
else:
raise Prevention
- Set per-request deadlines from estimated job length, not a global constant
- Enable gRPC keepalive on long-running generation streams
When it happens
Trigger: Client calls context.cancel() or closes the stream mid-generation; per-call deadline (timeout) shorter than total generation time for all segments; network drop between client and backend.
Common situations: UI 'stop' button cancelling generation; deadline set for short requests reused on long multi-segment avatar jobs; load balancer idle-cutting long-running streams.
Related errors
- Model not loaded
- start_image is not a readable staged file
- num_frames must not be negative
- audio input requires a LongCat-Video-Avatar-1.5 model
- audio is required for LongCat-Video-Avatar-1.5
AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15).
Data as JSON: /api/errors/fbf8a6f2e85ddfc3.
Report an issue: GitHub.