diff --git a/.changeset/good-flowers-promise.md b/.changeset/good-flowers-promise.md new file mode 100644 index 0000000000..109cee9718 --- /dev/null +++ b/.changeset/good-flowers-promise.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs-backend': patch +--- + +Fixed issue `syncEntityDocs` that would cause the `/sync` endpoint to be continuously called if the request fails diff --git a/plugins/techdocs/src/client.test.ts b/plugins/techdocs/src/client.test.ts index f66587a071..70c5f3568e 100644 --- a/plugins/techdocs/src/client.test.ts +++ b/plugins/techdocs/src/client.test.ts @@ -180,7 +180,11 @@ describe('TechDocsStorageClient', () => { mockFetchEventSource.mockImplementation(async (_url, options) => { const { onerror } = options; - onerror?.(new NotFoundError('Some not found warning')); + try { + onerror?.(new NotFoundError('Some not found warning')); + } catch (e) { + // do nothing + } }); // we await later after we emitted the error @@ -202,7 +206,11 @@ describe('TechDocsStorageClient', () => { mockFetchEventSource.mockImplementation(async (_url, options) => { const { onerror } = options; - onerror?.(new Error('Some other error')); + try { + onerror?.(new Error('Some other error')); + } catch (e) { + // do nothing + } }); await expect(promise).rejects.toThrow(Error); diff --git a/plugins/techdocs/src/client.ts b/plugins/techdocs/src/client.ts index d00be2a01f..9ea753b1e6 100644 --- a/plugins/techdocs/src/client.ts +++ b/plugins/techdocs/src/client.ts @@ -236,6 +236,7 @@ export class TechDocsStorageClient implements TechDocsStorageApi { onerror(err) { ctrl.abort(); reject(err); + throw err; // rethrow to stop the operation }, }); });