mirror of
https://github.com/logto-io/logto.git
synced 2024-12-30 20:33:54 -05:00
fix(core): fix cloudflare hostname not found error handler (#4316)
fix(core): fix cloudflare hostnme not found error handler
This commit is contained in:
parent
3c903b4778
commit
7bb60eeff8
2 changed files with 13 additions and 5 deletions
|
@ -149,4 +149,14 @@ describe('deleteDomain()', () => {
|
|||
expect(clearCustomDomainCache).toBeCalledTimes(1);
|
||||
expect(deleteDomainById).toBeCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should delete local record even if the record is not found in remote', async () => {
|
||||
findDomainById.mockResolvedValueOnce(mockDomainWithCloudflareData);
|
||||
deleteCustomHostname.mockRejectedValueOnce(
|
||||
new RequestError({ code: 'domain.cloudflare_not_found' })
|
||||
);
|
||||
await expect(deleteDomain(mockDomain.id)).resolves.not.toThrow();
|
||||
expect(clearCustomDomainCache).toBeCalledTimes(1);
|
||||
expect(deleteDomainById).toBeCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -103,14 +103,12 @@ export const createDomainLibrary = (queries: Queries) => {
|
|||
try {
|
||||
await deleteCustomHostname(hostnameProviderConfig, domain.cloudflareData.id);
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof RequestError && error.code === 'domain.cloudflare_not_found') {
|
||||
// Ignore not found error, since we are deleting the domain anyway
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(error instanceof RequestError) || error.code !== 'domain.cloudflare_not_found') {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await deleteDomainById(id);
|
||||
await clearCustomDomainCache(domain.domain);
|
||||
|
|
Loading…
Reference in a new issue