🔥 refactor(buildTrigger): remove unused imports and ProgressBarComponent
🐛 fix(buildTrigger): handle error response from server when starting a build
The ProgressBarComponent import was removed as it was not being used. The error handling was improved to handle the case where the server returns an error response when starting a build. The error message is now displayed to the user and the build state is reset.
This commit is contained in:
parent
38c2eaa897
commit
b9231aad8f
1 changed files with 6 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import { useContext, useEffect, useRef, useState } from "react";
|
import { useContext, useState } from "react";
|
||||||
import { Transition } from "@headlessui/react";
|
import { Transition } from "@headlessui/react";
|
||||||
import { Zap } from "lucide-react";
|
import { Zap } from "lucide-react";
|
||||||
import { validateNodes } from "../../../utils";
|
import { validateNodes } from "../../../utils";
|
||||||
|
|
@ -8,7 +8,6 @@ import { useSSE } from "../../../contexts/SSEContext";
|
||||||
import { typesContext } from "../../../contexts/typesContext";
|
import { typesContext } from "../../../contexts/typesContext";
|
||||||
import { alertContext } from "../../../contexts/alertContext";
|
import { alertContext } from "../../../contexts/alertContext";
|
||||||
import { postBuildInit } from "../../../controllers/API";
|
import { postBuildInit } from "../../../controllers/API";
|
||||||
import ProgressBarComponent from "../../ProgressBarComponent";
|
|
||||||
|
|
||||||
import RadialProgressComponent from "../../RadialProgress";
|
import RadialProgressComponent from "../../RadialProgress";
|
||||||
|
|
||||||
|
|
@ -100,6 +99,11 @@ export default function BuildTrigger({
|
||||||
eventSource.onerror = (error) => {
|
eventSource.onerror = (error) => {
|
||||||
console.error("EventSource failed:", error);
|
console.error("EventSource failed:", error);
|
||||||
eventSource.close();
|
eventSource.close();
|
||||||
|
if (error.data) {
|
||||||
|
const parsedData = JSON.parse(error.data);
|
||||||
|
setErrorData({ title: parsedData.error });
|
||||||
|
setIsBuilding(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// Step 3: Wait for the stream to finish
|
// Step 3: Wait for the stream to finish
|
||||||
while (!finished) {
|
while (!finished) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue