Skip to content

Commit 3943a95

Browse files
committed
fix: handle pre-aborted secondary signal in mergeAbortSignals
1 parent b33e17c commit 3943a95

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/api/providers/config-builder/request-config-builder.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,24 @@ export class RequestConfigBuilder<TOptions extends Record<string, any> = Record<
121121
return primarySignal
122122
}
123123

124+
// If both are aborted, return primary (as it is already aborted)
125+
if (primarySignal.aborted && secondarySignal.aborted) {
126+
return primarySignal
127+
}
128+
129+
// If only primary is aborted, return primary
124130
if (primarySignal.aborted) {
125131
return primarySignal
126132
}
127133

134+
// If only secondary is already aborted, create an immediately aborted controller
135+
if (secondarySignal.aborted) {
136+
const controller = new AbortController()
137+
controller.abort()
138+
return controller.signal
139+
}
140+
141+
// Both are active: merge with event listeners
128142
const controller = new AbortController()
129143

130144
primarySignal.addEventListener("abort", () => controller.abort(), { once: true })

0 commit comments

Comments
 (0)