Skip to content

Commit 16c0c90

Browse files
committed
fix(confluence): keep the 500 status when cancelling an errored response body
1 parent c22a623 commit 16c0c90

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎apps/sim/connectors/confluence/attachments.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,13 @@ describe('Confluence attachment listing', () => {
288288
it.each([
289289
['a complete body', () => 'upstream error'],
290290
['a body that never finishes', () => new ReadableStream<Uint8Array>()],
291+
[
292+
'a body stream that already errored',
293+
() =>
294+
new ReadableStream<Uint8Array>({
295+
start: (controller) => controller.error(new Error('connection reset')),
296+
}),
297+
],
291298
])('retries a transient 500 with %s instead of failing the listing', async (_, body) => {
292299
let failed = false
293300
fetchMock.mockImplementation(async () => {

‎apps/sim/connectors/confluence/attachments.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ const METADATA_RETRY_OPTIONS: RetryOptions = {
163163
requestId: opaqueHeader(response, 'x-arequestid'),
164164
})
165165
if (response.status !== 500) return response
166-
await response.body?.cancel()
166+
await response.body?.cancel().catch(() => undefined)
167167
throw metadataServerError(response.status)
168168
},
169169
retryCondition: (error) =>
@@ -196,7 +196,7 @@ function isServerFailure(error: unknown): error is Error & { status: number } {
196196
async function readMetadata(response: Response): Promise<unknown> {
197197
if (!response.ok) {
198198
if (response.status === 401) throw await unauthorizedAttachmentError(response)
199-
await response.body?.cancel()
199+
await response.body?.cancel().catch(() => undefined)
200200
if (response.status >= 500) throw metadataServerError(response.status)
201201
throw new Error(
202202
response.status === 403

0 commit comments

Comments
 (0)