Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

refactor(core): remove abort event error on init (#9465)

doodlewind8227d689534e
diff --git a/packages/frontend/core/src/desktop/pages/root/index.tsx b/packages/frontend/core/src/desktop/pages/root/index.tsx
index 05004d446c..1f0e011600 100644
--- a/packages/frontend/core/src/desktop/pages/root/index.tsx
+++ b/packages/frontend/core/src/desktop/pages/root/index.tsx
@@ -19,15 +19,9 @@ export const RootWrapper = () => {
const abortController = new AbortController();
defaultServerService.server
.waitForConfigRevalidation(abortController.signal)
- .then(() => {
- setIsServerReady(true);
- })
- .catch(error => {
- console.error(error);
- });
- return () => {
- abortController.abort();
- };
+ .then(() => setIsServerReady(true))
+ .catch(console.error);
+ return () => abortController.abort();
}, [defaultServerService, isServerReady]);
return (
diff --git a/packages/frontend/core/src/mobile/pages/root/index.tsx b/packages/frontend/core/src/mobile/pages/root/index.tsx
index 0dccf2bf6b..0f96322311 100644
--- a/packages/frontend/core/src/mobile/pages/root/index.tsx
+++ b/packages/frontend/core/src/mobile/pages/root/index.tsx
@@ -17,15 +17,9 @@ export const RootWrapper = () => {
const abortController = new AbortController();
defaultServerService.server
.waitForConfigRevalidation(abortController.signal)
- .then(() => {
- setIsServerReady(true);
- })
- .catch(error => {
- console.error(error);
- });
- return () => {
- abortController.abort();
- };
+ .then(() => setIsServerReady(true))
+ .catch(console.error);
+ return () => abortController.abort();
}, [defaultServerService, isServerReady]);
return (
diff --git a/packages/frontend/core/src/modules/cloud/entities/server.ts b/packages/frontend/core/src/modules/cloud/entities/server.ts
index 2ffecca218..f8af875be5 100644
--- a/packages/frontend/core/src/modules/cloud/entities/server.ts
+++ b/packages/frontend/core/src/modules/cloud/entities/server.ts
@@ -100,11 +100,16 @@ export class Server extends Entity<{
);
async waitForConfigRevalidation(signal?: AbortSignal) {
- this.revalidateConfig();
- await this.isConfigRevalidating$.waitFor(
- isRevalidating => !isRevalidating,
- signal
- );
+ try {
+ this.revalidateConfig();
+ await this.isConfigRevalidating$.waitFor(
+ isRevalidating => !isRevalidating,
+ signal
+ );
+ } catch (error) {
+ if (error instanceof Event && error.type === 'abort') return;
+ console.error('Config revalidation failed:', error);
+ }
}
override dispose(): void {