Skip to content

Commit 94f7337

Browse files
vvoclaude
andauthored
fix: handle empty stream error in e2e test route (#1039)
The server rejects empty multipart uploads with "Invalid body". Catch the error in the route and return { resolved: true } so the test can verify the upload resolved (no deadlock) regardless of the server response. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0ab77bb commit 94f7337

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

test/next/src/app/vercel/blob/api/app/empty-stream-multipart/route.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,20 @@ export async function POST(request: Request): Promise<NextResponse> {
2222
},
2323
});
2424

25-
const blob = await vercelBlob.put(pathname, emptyStream, {
26-
access: 'public',
27-
multipart: true,
28-
addRandomSuffix: true,
29-
});
25+
try {
26+
const blob = await vercelBlob.put(pathname, emptyStream, {
27+
access: 'public',
28+
multipart: true,
29+
addRandomSuffix: true,
30+
});
3031

31-
return NextResponse.json(blob);
32+
return NextResponse.json(blob);
33+
} catch (error) {
34+
// The server rejects empty multipart uploads ("Invalid body") which is
35+
// expected. The important thing is that put() resolved instead of hanging.
36+
return NextResponse.json(
37+
{ resolved: true, error: (error as Error).message },
38+
{ status: 400 },
39+
);
40+
}
3241
}

test/next/test/@vercel/blob/index.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ test.describe('@vercel/blob', () => {
5252
timeout: 15000, // Should resolve fast, not deadlock
5353
},
5454
);
55-
// The upload resolves (no deadlock). The server may reject the empty
56-
// multipart upload, but the important thing is it doesn't hang.
57-
expect(res.status()).toBeLessThan(500);
55+
// The server rejects the empty multipart upload (400) which is fine.
56+
// The important thing is it resolved instead of hanging (15s timeout).
57+
const data = (await res.json()) as { resolved: boolean };
58+
expect(data.resolved).toBe(true);
5859
});
5960
});
6061

0 commit comments

Comments
 (0)