fix(intake): avoid empty chunk upload 502
This commit is contained in:
parent
11e67ff4ed
commit
6dd75c502a
@ -151,10 +151,12 @@ export async function POST(request: NextRequest, context: RouteContext) {
|
||||
const uploadedChunks = savedChunks.filter(Boolean).length
|
||||
|
||||
if (uploadedChunks < totalChunks) {
|
||||
return new NextResponse(null, {
|
||||
status: 204,
|
||||
return new NextResponse('', {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Cache-Control': 'no-store',
|
||||
'Content-Length': '0',
|
||||
'X-Upload-Chunk-Status': 'pending',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@ -309,8 +309,9 @@ describe('POST /api/intake/non-integrated/upload', () => {
|
||||
}
|
||||
|
||||
const firstResponse = await uploadChunk(0, fileBytes.slice(0, 10))
|
||||
expect(firstResponse.status).toBe(204)
|
||||
expect(firstResponse.body).toBeNull()
|
||||
expect(firstResponse.status).toBe(200)
|
||||
expect(firstResponse.headers.get('X-Upload-Chunk-Status')).toBe('pending')
|
||||
await expect(firstResponse.text()).resolves.toBe('')
|
||||
|
||||
const completedResponse = await uploadChunk(1, fileBytes.slice(10))
|
||||
const completedPayload = await completedResponse.json()
|
||||
|
||||
@ -222,7 +222,10 @@ async function uploadNonIntegratedFileInChunks<T>(params: {
|
||||
},
|
||||
)
|
||||
|
||||
if (response.status === 204) {
|
||||
if (
|
||||
response.status === 204 ||
|
||||
response.headers.get('X-Upload-Chunk-Status') === 'pending'
|
||||
) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user