Skip to content

Commit 334b347

Browse files
committed
Timeout downloading after 30 seconds
1 parent b312273 commit 334b347

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/app/api/proxy/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ export async function GET(req: NextRequest) {
3939
async function downloadFile(params: { url: URL, maxBytes: number }): Promise<Blob> {
4040
const { url, maxBytes } = params
4141
const abortController = new AbortController()
42+
const timeoutSignal = AbortSignal.timeout(30 * 1000)
4243
const response = await fetch(url, {
43-
signal: AbortSignal.any([abortController.signal])
44+
signal: AbortSignal.any([abortController.signal, timeoutSignal])
4445
})
4546
if (!response.body) {
4647
throw new Error("Response body unavailable")

0 commit comments

Comments
 (0)