-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[WEB-2706] fix: Add fallback when db initialisation fails #5973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a8728fc
2d7c10c
9dd5e89
3a87397
c3355bd
a0267f1
3de955d
84d6ba1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,44 @@ export const logError = (e: any) => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const logInfo = console.info; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const addIssueToPersistanceLayer = async (issue: TIssue) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const issuePartial = pick({ ...JSON.parse(JSON.stringify(issue)) }, [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "id", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "name", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "state_id", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "sort_order", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "completed_at", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "estimate_point", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "priority", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "start_date", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "target_date", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "sequence_id", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "project_id", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "parent_id", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "created_at", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "updated_at", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "created_by", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "updated_by", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "is_draft", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "archived_at", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "state__group", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cycle_id", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "link_count", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "attachment_count", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "sub_issues_count", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "assignee_ids", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "label_ids", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "module_ids", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "type_id", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "description_html", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await updateIssue({ ...issuePartial, is_local_update: 1 }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logError("Error while adding issue to db"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+22
to
+58
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve error handling and code structure in Several improvements can be made to enhance reliability and maintainability:
Here's the suggested implementation: +const ISSUE_PERSISTENCE_FIELDS = [
+ "id", "name", "state_id", "sort_order", "completed_at", "estimate_point",
+ "priority", "start_date", "target_date", "sequence_id", "project_id",
+ "parent_id", "created_at", "updated_at", "created_by", "updated_by",
+ "is_draft", "archived_at", "state__group", "cycle_id", "link_count",
+ "attachment_count", "sub_issues_count", "assignee_ids", "label_ids",
+ "module_ids", "type_id", "description_html"
+] as const;
-export const addIssueToPersistanceLayer = async (issue: TIssue) => {
+export const addIssueToPersistanceLayer = async (issue: TIssue): Promise<boolean> => {
try {
- const issuePartial = pick({ ...JSON.parse(JSON.stringify(issue)) }, [
- "id", "name", "state_id", /* ... other fields ... */
- ]);
+ const issuePartial = pick(issue, ISSUE_PERSISTENCE_FIELDS);
await updateIssue({ ...issuePartial, is_local_update: 1 });
+ return true;
} catch (e) {
- logError("Error while adding issue to db");
+ logError(`Failed to add issue ${issue.id} to db: ${e.message}`);
+ return false;
}
};📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const updatePersistentLayer = async (issueIds: string | string[]) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (typeof issueIds === "string") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| issueIds = [issueIds]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -28,38 +66,7 @@ export const updatePersistentLayer = async (issueIds: string | string[]) => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const issue = rootStore.issue.issues.getIssueById(issueId); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (issue) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // JSON.parse(JSON.stringify(issue)) is used to remove the mobx observables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const issuePartial = pick({ ...dbIssue, ...JSON.parse(JSON.stringify(issue)) }, [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "id", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "name", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "state_id", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "sort_order", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "completed_at", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "estimate_point", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "priority", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "start_date", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "target_date", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "sequence_id", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "project_id", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "parent_id", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "created_at", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "updated_at", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "created_by", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "updated_by", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "is_draft", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "archived_at", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "state__group", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cycle_id", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "link_count", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "attachment_count", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "sub_issues_count", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "assignee_ids", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "label_ids", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "module_ids", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "type_id", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "description_html", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await updateIssue({ ...issuePartial, is_local_update: 1 }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| addIssueToPersistanceLayer(issue); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix async operation handling in The current implementation has potential issues:
Here's the suggested fix: export const updatePersistentLayer = async (issueIds: string | string[]) => {
if (typeof issueIds === "string") {
issueIds = [issueIds];
}
- issueIds.forEach(async (issueId) => {
+ await Promise.all(issueIds.map(async (issueId) => {
const dbIssue = await persistence.getIssue(issueId);
const issue = rootStore.issue.issues.getIssueById(issueId);
- if (issue) {
- addIssueToPersistanceLayer(issue);
+ if (!issue) {
+ logError(`Issue ${issueId} not found in store`);
+ return;
}
- });
+
+ const success = await addIssueToPersistanceLayer(issue);
+ if (!success) {
+ logError(`Failed to update issue ${issueId} in persistent layer`);
+ }
+ }));
};
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,8 @@ import { makeObservable, observable, runInAction, action } from "mobx"; | |||||||||||||||||||||||||||||||||||||
| import { TIssue, TInboxIssue, TInboxIssueStatus, TInboxDuplicateIssueDetails } from "@plane/types"; | ||||||||||||||||||||||||||||||||||||||
| // helpers | ||||||||||||||||||||||||||||||||||||||
| import { EInboxIssueStatus } from "@/helpers/inbox.helper"; | ||||||||||||||||||||||||||||||||||||||
| // local db | ||||||||||||||||||||||||||||||||||||||
| import { addIssueToPersistanceLayer } from "@/local-db/utils/utils"; | ||||||||||||||||||||||||||||||||||||||
| // services | ||||||||||||||||||||||||||||||||||||||
| import { InboxIssueService } from "@/services/inbox"; | ||||||||||||||||||||||||||||||||||||||
| import { IssueService } from "@/services/issue"; | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -88,10 +90,16 @@ export class InboxIssueStore implements IInboxIssueStore { | |||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||
| if (!this.issue.id) return; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| const inboxIssue = await this.inboxIssueService.update(this.workspaceSlug, this.projectId, this.issue.id, { | ||||||||||||||||||||||||||||||||||||||
| status: status, | ||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||
| runInAction(() => set(this, "status", inboxIssue?.status)); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // If issue accepted sync issue to local db | ||||||||||||||||||||||||||||||||||||||
| if (status === EInboxIssueStatus.ACCEPTED) { | ||||||||||||||||||||||||||||||||||||||
| addIssueToPersistanceLayer(inboxIssue.issue); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+99
to
+102
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enhance error handling for local DB synchronization. The local DB sync operation is not wrapped in error handling, which could lead to silent failures. Consider:
Here's a suggested improvement: // If issue accepted sync issue to local db
if (status === EInboxIssueStatus.ACCEPTED) {
- addIssueToPersistanceLayer(inboxIssue.issue);
+ try {
+ await Promise.race([
+ addIssueToPersistanceLayer(inboxIssue.issue),
+ new Promise((_, reject) =>
+ setTimeout(() => reject(new Error('DB sync timeout')), 5000)
+ )
+ ]);
+ } catch (error) {
+ console.error('Failed to sync issue to local DB:', error);
+ // Implement fallback mechanism here
+ }
}📝 Committable suggestion
Suggested change
💡 Codebase verification Based on the implementation found, I can now provide the final response: DB error handling needs improvement The current implementation of
Suggested improvements:
🔗 Analysis chainVerify the local DB sync implementation. Let's verify the implementation of Let me gather more information about the error handling in the implementation. Let me try one more search to find the complete implementation and error handling: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for the implementation and error handling in addIssueToPersistanceLayer
echo "Searching for addIssueToPersistanceLayer implementation..."
rg -A 10 "export.*addIssueToPersistanceLayer"
# Search for DB initialization failure handling
echo "Searching for DB initialization handling..."
rg -l "db.*initialize.*catch|db.*init.*error"
Length of output: 1069 Script: #!/bin/bash
# Get full implementation of addIssueToPersistanceLayer including error handling
rg -A 20 "export const addIssueToPersistanceLayer" web/core/local-db/utils/utils.ts
# Search for any DB-related error handling patterns
rg "catch.*db|db.*error" web/core/local-db/utils/utils.ts
# Look for where the DB is initialized
rg -A 10 "initializeDb|setupDb|createDb" web/core/local-db/
Length of output: 706 Script: #!/bin/bash
# Search for the complete file content to see the full implementation
cat web/core/local-db/utils/utils.ts
# Also search for any error handling patterns in the file
rg "catch|throw|error" web/core/local-db/utils/utils.ts
# Look for DB initialization in index files
rg -A 10 "db" web/core/local-db/index.ts
Length of output: 5661 |
||||||||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||||||||
| runInAction(() => set(this, "status", previousData.status)); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,6 +22,8 @@ import { | |||||||||||||||||||||||||
| import { EDraftIssuePaginationType } from "@/constants/workspace-drafts"; | ||||||||||||||||||||||||||
| // helpers | ||||||||||||||||||||||||||
| import { getCurrentDateTimeInISO, convertToISODateString } from "@/helpers/date-time.helper"; | ||||||||||||||||||||||||||
| // local-db | ||||||||||||||||||||||||||
| import { addIssueToPersistanceLayer } from "@/local-db/utils/utils"; | ||||||||||||||||||||||||||
| // services | ||||||||||||||||||||||||||
| import workspaceDraftService from "@/services/issue/workspace_draft.service"; | ||||||||||||||||||||||||||
| // types | ||||||||||||||||||||||||||
|
|
@@ -59,7 +61,7 @@ export interface IWorkspaceDraftIssues { | |||||||||||||||||||||||||
| payload: Partial<TWorkspaceDraftIssue | TIssue> | ||||||||||||||||||||||||||
| ) => Promise<TWorkspaceDraftIssue | undefined>; | ||||||||||||||||||||||||||
| deleteIssue: (workspaceSlug: string, issueId: string) => Promise<void>; | ||||||||||||||||||||||||||
| moveIssue: (workspaceSlug: string, issueId: string, payload: Partial<TWorkspaceDraftIssue>) => Promise<void>; | ||||||||||||||||||||||||||
| moveIssue: (workspaceSlug: string, issueId: string, payload: Partial<TWorkspaceDraftIssue>) => Promise<TIssue>; | ||||||||||||||||||||||||||
| addCycleToIssue: ( | ||||||||||||||||||||||||||
| workspaceSlug: string, | ||||||||||||||||||||||||||
| issueId: string, | ||||||||||||||||||||||||||
|
|
@@ -348,6 +350,10 @@ export class WorkspaceDraftIssues implements IWorkspaceDraftIssues { | |||||||||||||||||||||||||
| total_count: this.paginationInfo.total_count - 1, | ||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // sync issue to local db | ||||||||||||||||||||||||||
| addIssueToPersistanceLayer(response); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
Comment on lines
+353
to
+356
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add error handling for persistence layer sync. While the sync to persistence layer is correctly placed after the successful API response, it lacks error handling. Consider wrapping it in a try-catch block to prevent any persistence failures from affecting the UI. // sync issue to local db
- addIssueToPersistanceLayer(response);
+ try {
+ await addIssueToPersistanceLayer(response);
+ } catch (error) {
+ // Log the error but don't throw to prevent UI disruption
+ console.error("Failed to sync issue to persistence layer:", error);
+ }📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||
| // Update draft issue count in workspaceUserInfo | ||||||||||||||||||||||||||
| this.updateWorkspaceUserDraftIssueCount(workspaceSlug, -1); | ||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Based on the search results, particularly from
web/core/local-db/utils/schemas.tsand other files, I can now generate a final response.Update BOOLEAN_FIELDS constant to include all relevant boolean fields
The constant should include additional boolean fields found in the codebase:
is_draftis_local_updateis_botis_favoriteis_lockedis_subscribedThese fields are used across various models and schemas in the application, particularly in issues and pages.
🔗 Analysis chain
Verify completeness of boolean fields list.
Let's ensure we haven't missed any boolean fields that should be included in this constant.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 213
Script:
Length of output: 105064