-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
Description
When multiple callTool() requests run concurrently (e.g. generating variants with Pro model), the Stitch server occasionally closes the underlying socket. The SDK surfaces this as an unrecoverable TypeError: fetch failed to the caller, even though the operation would succeed on a simple retry with a fresh connection.
Steps to reproduce
const client = new StitchToolClient({ apiKey: "..." });
const project = await client.callTool("create_project", { title: "test" });
const projectId = project.name.replace("projects/", "");
const screen = await client.callTool("generate_screen_from_text", {
projectId,
prompt: "a dashboard",
modelId: "GEMINI_3_PRO",
});
const screenId = screen.outputComponents[0].design.screens[0].id;
// Fire 3 concurrent variant requests — one or more will fail
await Promise.allSettled([
client.callTool("generate_variants", {
projectId,
selectedScreenIds: [screenId],
prompt: "dark theme",
variantOptions: { variantCount: 2, creativeRange: "EXPLORE" },
modelId: "GEMINI_3_PRO",
}),
client.callTool("generate_variants", { /* ... */ }),
client.callTool("generate_variants", { /* ... */ }),
]);Actual behavior
Stitch Transport Error: TypeError: fetch failed
[cause]: SocketError: other side closed
One or more requests fail with no retry attempt. The transport's onerror sets isConnected = false, but the in-flight request is already lost.
Expected behavior
callTool should detect transient network errors (e.g. fetch failed, ECONNRESET, socket), reconnect, and retry the request once before throwing.
Environment
@google/stitch-sdk0.0.3- Node.js 22
- macOS
- Reproducible with
GEMINI_3_PROmodel under concurrent variant generation
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels