Skip to content

Commit 5655266

Browse files
authored
fix(ui): handle abort() call signal error (#7390)
## Description Swallows `.abort()` call signal errors - [x] I have read and understand the [CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md) document in this repository. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## Checklist: - [x] Existing test suite passes locally with my changes
1 parent f9e5573 commit 5655266

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

packages/ui/src/elements/Autosave/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,13 @@ export const Autosave: React.FC<Props> = ({
220220

221221
return () => {
222222
if (autosaveTimeout) clearTimeout(autosaveTimeout)
223-
if (abortController.signal) abortController.abort()
223+
if (abortController.signal) {
224+
try {
225+
abortController.abort()
226+
} catch (error) {
227+
// swallow error
228+
}
229+
}
224230
setSaving(false)
225231
}
226232
}, [

packages/ui/src/elements/WhereBuilder/Condition/Relationship/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,13 @@ export const RelationshipField: React.FC<Props> = (props) => {
248248

249249
return () => {
250250
abortControllers.forEach((controller) => {
251-
if (controller.signal) controller.abort()
251+
if (controller.signal) {
252+
try {
253+
controller.abort()
254+
} catch (error) {
255+
// swallow error
256+
}
257+
}
252258
})
253259
}
254260
}, [i18n, loadRelationOptions, relationTo])

packages/ui/src/hooks/usePayloadAPI.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ export const usePayloadAPI: UsePayloadAPI = (url, options = {}) => {
8989
}
9090

9191
return () => {
92-
abortController.abort()
92+
try {
93+
abortController.abort()
94+
} catch (error) {
95+
// swallow error
96+
}
9397
}
9498
}, [url, locale, search, i18n.language, initialData])
9599

packages/ui/src/providers/DocumentInfo/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,11 @@ const DocumentInfo: React.FC<
455455
}
456456

457457
return () => {
458-
abortController.abort()
458+
try {
459+
abortController.abort()
460+
} catch (error) {
461+
// swallow error
462+
}
459463
}
460464
}, [
461465
api,

0 commit comments

Comments
 (0)