0
Fork 0
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:
wangsijie 2023-08-14 10:51:06 +08:00 committed by GitHub
parent 3c903b4778
commit 7bb60eeff8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View file

@ -149,4 +149,14 @@ describe('deleteDomain()', () => {
expect(clearCustomDomainCache).toBeCalledTimes(1); expect(clearCustomDomainCache).toBeCalledTimes(1);
expect(deleteDomainById).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);
});
}); });

View file

@ -103,12 +103,10 @@ export const createDomainLibrary = (queries: Queries) => {
try { try {
await deleteCustomHostname(hostnameProviderConfig, domain.cloudflareData.id); await deleteCustomHostname(hostnameProviderConfig, domain.cloudflareData.id);
} catch (error: unknown) { } catch (error: unknown) {
if (error instanceof RequestError && error.code === 'domain.cloudflare_not_found') { // Ignore not found error, since we are deleting the domain anyway
// Ignore not found error, since we are deleting the domain anyway if (!(error instanceof RequestError) || error.code !== 'domain.cloudflare_not_found') {
return; throw error;
} }
throw error;
} }
} }