Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(frontend): prevent race condition and improve error handling in legacy issue creation (#17962)

boojack4c96f272fb95
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue
index 8272abd974..506b80e099 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue
@@ -74,7 +74,11 @@ import {
rolloutServiceClientConnect,
} from "@/grpcweb";
import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";
-import { useSheetV1Store, useCurrentProjectV1 } from "@/store";
+import {
+ useSheetV1Store,
+ useCurrentProjectV1,
+ pushNotification,
+} from "@/store";
import { CreateIssueRequestSchema } from "@/types/proto-es/v1/issue_service_pb";
import { IssueSchema, Issue_Type } from "@/types/proto-es/v1/issue_service_pb";
import { CreatePlanRequestSchema } from "@/types/proto-es/v1/plan_service_pb";
@@ -145,6 +149,10 @@ const issueCreateErrorList = computed(() => {
});
const doCreateIssue = async () => {
+ // Prevent race condition: check if already creating
+ if (loading.value) {
+ return;
+ }
loading.value = true;
// Run SQL check for database change issues.
@@ -162,7 +170,10 @@ const doCreateIssue = async () => {
issue.value.title,
issue.value.description
);
- if (!createdPlan) return;
+ if (!createdPlan) {
+ loading.value = false;
+ return;
+ }
issue.value.plan = createdPlan.name;
issue.value.planEntity = createdPlan;
@@ -192,7 +203,14 @@ const doCreateIssue = async () => {
issueSlug: issueV1Slug(createdIssue.name, createdIssue.title),
},
});
- } catch {
+ } catch (error) {
+ console.error("Failed to create issue:", error);
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: t("common.error"),
+ description: String(error),
+ });
loading.value = false;
}
};
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
index 8e1d55b66c..748a165b21 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
@@ -137,6 +137,9 @@ const pendingReviewAction = ref<IssueReviewAction | undefined>(undefined);
const pendingStatusAction = ref<IssueStatusAction | undefined>(undefined);
const pendingRolloutAction = ref<RolloutAction | undefined>(undefined);
+// Loading state for issue creation to prevent race conditions
+const isCreatingIssue = ref(false);
+
// Get the stage that contains database creation or export tasks
const rolloutStage = computed(() => {
if (!rollout.value) return undefined;
@@ -480,6 +483,12 @@ const handlePerformAction = async (action: UnifiedAction) => {
const handleIssueCreate = async () => {
if (!plan?.value) return;
+ // Prevent race condition: check if already creating issue
+ if (isCreatingIssue.value) {
+ return;
+ }
+ isCreatingIssue.value = true;
+
try {
await doCreateIssue();
} catch (error) {
@@ -490,6 +499,8 @@ const handleIssueCreate = async () => {
title: "Failed to create issue",
description: String(error),
});
+ } finally {
+ isCreatingIssue.value = false;
}
};
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue
index 0afe0932cd..ffb588e503 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue
@@ -103,6 +103,10 @@ const planCreateErrorList = computed(() => {
});
const doCreatePlan = async () => {
+ // Prevent race condition: check if already creating
+ if (loading.value) {
+ return;
+ }
loading.value = true;
try {
@@ -117,7 +121,10 @@ const doCreatePlan = async () => {
plan: plan.value,
});
const createdPlan = await planServiceClientConnect.createPlan(request);
- if (!createdPlan) return;
+ if (!createdPlan) {
+ loading.value = false;
+ return;
+ }
nextTick(() => {
router.replace({
@@ -152,7 +159,10 @@ const doCreateDataExportIssue = async () => {
plan: plan.value,
});
const createdPlan = await planServiceClientConnect.createPlan(planRequest);
- if (!createdPlan) return;
+ if (!createdPlan) {
+ loading.value = false;
+ return;
+ }
// Create the issue
const issueRequest = create(CreateIssueRequestSchema, {