chore: add changeset for AbortSignal fix in msgraph provider
Signed-off-by: Lokesh Kaki <lokeshkaki1@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend-module-msgraph': patch
|
||||
---
|
||||
|
||||
Fixed scheduler task remaining stuck in running state after pod termination by propagating AbortSignal into MicrosoftGraphOrgEntityProvider.read()
|
||||
+7
-2
@@ -286,19 +286,24 @@ describe('MicrosoftGraphOrgEntityProvider', () => {
|
||||
readMicrosoftGraphOrgMocked.mockImplementationOnce(
|
||||
async (_client, _tenantId, options) => {
|
||||
if (options.signal?.aborted) {
|
||||
throw new DOMException('The operation was aborted', 'AbortError');
|
||||
const error = new Error('The operation was aborted');
|
||||
error.name = 'AbortError';
|
||||
throw error;
|
||||
}
|
||||
return { users: [], groups: [] };
|
||||
},
|
||||
);
|
||||
|
||||
const taskDef = localTaskRunner.getTasks()[0];
|
||||
// Should resolve without throwing (the error is caught and logged internally)
|
||||
// Should resolve without throwing (abort is caught and logged at debug level)
|
||||
await (taskDef.fn as (signal: AbortSignal) => Promise<void>)(
|
||||
controller.signal,
|
||||
);
|
||||
|
||||
expect(entityProviderConnection.applyMutation).not.toHaveBeenCalled();
|
||||
expect(logger.debug).toHaveBeenCalledWith(
|
||||
expect.stringContaining('refresh aborted due to shutdown'),
|
||||
);
|
||||
});
|
||||
|
||||
it('fail without schedule and scheduler', () => {
|
||||
|
||||
+6
@@ -397,6 +397,12 @@ export class MicrosoftGraphOrgEntityProvider implements EntityProvider {
|
||||
try {
|
||||
await this.read({ logger, signal: abortSignal });
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.name === 'AbortError') {
|
||||
logger.debug(
|
||||
`${this.getProviderName()} refresh aborted due to shutdown`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
logger.error(
|
||||
`${this.getProviderName()} refresh failed, ${error}`,
|
||||
error,
|
||||
|
||||
Reference in New Issue
Block a user