mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2707] [Issue]: /game/generate-assets serially generates up to 10 portraits with no abort — zombie work after client timeout (perceived hang) #1352
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1352
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2707
Originally assigned to: @SpicyMarinara on GitHub.
Summary
POST /game/generate-assetsgenerates all game assets inline and sequentially — one background, one illustration, then up to 10 NPC portraits one-at-a-time — with no request-scoped AbortSignal. Worst case the server blocks for ~50+ minutes on a slow image backend while the client gives up at 240s, and the server keeps generating zombie portraits after no one is waiting (perceived hang, wasted backend, retries queue behind it).Expected behavior
Asset generation should be bounded, cancellable when the client disconnects, and run with limited concurrency so a slow image backend can't make game creation/scene population appear to hang for many minutes.
Actual behavior
The handler runs one
generateBackground, onegenerateSceneIllustration, then iteratesinput.npcsNeedingAvatars(Zod.max(10)) in a plainforloopawaitinggenerateNpcPortraitone at a time. EachgenerateImagehas its own 5-minute deadline (IMAGE_GEN_TIMEOUT = 300_000), but the handler never inspects a request AbortSignal between portraits and passes no request-scoped signal intogenerateNpcPortrait/generateImage. The client wraps the call inwithTimeout(..., 240_000). So when the client aborts at 240s, the server keeps generating every portrait to completion (nothing propagates the abort), and a subsequent/generate-assetsretry queues behind the still-running work.How it breaks the pipeline
Code trace (staging @
b826f8f4):packages/server/src/routes/game.routes.ts:7466(generateBackground),~:7558(generateSceneIllustration),:7653-7700(sequential NPC portrait loop); Zod.max(10)at:7054-7064.packages/server/src/services/image/image-generation.ts:226(IMAGE_GEN_TIMEOUT = 300_000, per-call only).GameSurface.tsx:4247-4253(withTimeout(..., GAME_ASSET_GENERATION_TIMEOUT_MS=240_000)+ "continues without assets" toast).Steps to reproduce
Suggested fix
Pass a request-linked AbortSignal (from
req.raw) down throughgenerateNpcPortrait/generateBackgroundintogenerateImage, aborting the in-flight fetch on client disconnect and bailing out of the NPC loop when aborted. Generate portraits with bounded concurrency (e.g.p-limit2-3) instead of fully sequentially, and cap the total handler wall-clock under the client's 240s so server and client agree.Environment
b826f8f4)Additional context
Found via a systematic multi-agent audit of Game Mode. A second "infinite loading" source (asset population) distinct from the setup hang. Part of a set of game-mode issues filed together.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Jun 21, 2026):
Fixed on the issue sweep branch. /game/generate-assets now creates a response-tied AbortSignal with a 220s wall-clock cap, passes it into background/illustration/NPC portrait generation, and stops taking new portrait work when the client disconnects or the route deadline fires. Game image helpers now thread that signal into generateImage, and image-generation provider fetches combine the caller signal with their existing per-image timeout so in-flight requests can actually abort. NPC portraits now run with bounded concurrency of 2 instead of serially generating up to 10 portraits. Final pnpm validation is deferred until the full sweep is complete.