From 9be17462224330d61492c4bd554f254429b7a9fe Mon Sep 17 00:00:00 2001 From: samaradel Date: Sun, 17 Nov 2024 17:07:21 +0200 Subject: [PATCH 1/7] Handle rented node in grace period --- .../node_selector/TfAutoNodeSelector.vue | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue b/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue index abd4e6f3e9..968536afd7 100644 --- a/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue +++ b/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue @@ -151,6 +151,9 @@ import { computed, nextTick, onMounted, onUnmounted, type PropType, ref } from " // eslint-disable-next-line @typescript-eslint/no-unused-vars import type { VCard } from "vuetify/components/VCard"; +import { createCustomToast, ToastType } from "@/utils/custom_toast"; +import { normalizeError } from "@/utils/helpers"; + import { useAsync, usePagination, useWatchDeep } from "../../hooks"; import { ValidatorStatus } from "../../hooks/form_validator"; import { useGrid } from "../../stores"; @@ -167,7 +170,6 @@ import { validateRentContract, } from "../../utils/nodeSelector"; import TfNodeDetailsCard from "./TfNodeDetailsCard.vue"; - export default { name: "TfAutoNodeSelector", components: { TfNodeDetailsCard }, @@ -299,14 +301,26 @@ export default { const nodeInputValidateTask = useAsync( async node => { - if (node && node?.rentContractId !== 0) { - const { state } = await gridStore.grid.contracts.get({ - id: node?.rentContractId, - }); - if (state.gracePeriod) { - return false; + try { + if (node && node.rentContractId !== 0) { + const { state } = await gridStore.grid.contracts.get({ + id: node?.rentContractId, + }); + if (state.gracePeriod) { + createCustomToast( + `You can't deploy on node ${node.nodeId}, its rent contract is in grace period.`, + ToastType.danger, + ); + } } + } catch (error) { + const err = normalizeError( + error, + "Something went wrong while checking status of the node. Please check your connection and try again.", + ); + throw err; } + const nodeCapacityValid = await checkNodeCapacityPool(gridStore, node, props.filters); const rentContractValid = props.filters.dedicated ? await validateRentContract(gridStore, node) : true; From ad03f55f7f9e50018dcb51d5a35bc8118ca526c4 Mon Sep 17 00:00:00 2001 From: samaradel Date: Tue, 19 Nov 2024 12:23:40 +0200 Subject: [PATCH 2/7] Handle Error --- .../src/components/node_selector/TfAutoNodeSelector.vue | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue b/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue index 968536afd7..cc9c6167ca 100644 --- a/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue +++ b/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue @@ -307,10 +307,7 @@ export default { id: node?.rentContractId, }); if (state.gracePeriod) { - createCustomToast( - `You can't deploy on node ${node.nodeId}, its rent contract is in grace period.`, - ToastType.danger, - ); + throw `You can't deploy on node ${node.nodeId}, its rent contract is in grace period.`; } } } catch (error) { From 54627d8ce13c20c21398f27046e6611ce22d40d1 Mon Sep 17 00:00:00 2001 From: samaradel Date: Fri, 22 Nov 2024 03:06:36 +0200 Subject: [PATCH 3/7] Remove the error toast --- packages/playground/src/utils/nodeSelector.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/playground/src/utils/nodeSelector.ts b/packages/playground/src/utils/nodeSelector.ts index 1a87bacf80..bfb4dd5b43 100644 --- a/packages/playground/src/utils/nodeSelector.ts +++ b/packages/playground/src/utils/nodeSelector.ts @@ -229,10 +229,7 @@ export async function validateRentContract( id: node.rentContractId, }); if (contractInfo.state.gracePeriod) { - createCustomToast( - `You can't deploy on node ${node.nodeId}, its rent contract is in grace period.`, - ToastType.danger, - ); + throw `You can't deploy on node ${node.nodeId}, its rent contract is in grace period.`; } } From b674138bb492d5c2251255a412302ba44f951c4d Mon Sep 17 00:00:00 2001 From: samaradel Date: Mon, 25 Nov 2024 12:28:07 +0200 Subject: [PATCH 4/7] Remove unused imports --- .../src/components/node_selector/TfAutoNodeSelector.vue | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue b/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue index cc9c6167ca..91be8abd5b 100644 --- a/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue +++ b/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue @@ -148,10 +148,7 @@ import { RequestError } from "@threefold/types"; import type AwaitLock from "await-lock"; import equals from "lodash/fp/equals.js"; import { computed, nextTick, onMounted, onUnmounted, type PropType, ref } from "vue"; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import type { VCard } from "vuetify/components/VCard"; -import { createCustomToast, ToastType } from "@/utils/custom_toast"; import { normalizeError } from "@/utils/helpers"; import { useAsync, usePagination, useWatchDeep } from "../../hooks"; From ff6bbd28b969a25c8bfb1e3f78f65aa7399c7c6d Mon Sep 17 00:00:00 2001 From: samaradel Date: Mon, 2 Dec 2024 15:23:32 +0200 Subject: [PATCH 5/7] Add timeout with promise to catch grace period error --- .../src/components/node_selector/TfAutoNodeSelector.vue | 6 +++++- packages/playground/src/utils/nodeSelector.ts | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue b/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue index 91be8abd5b..277948ebb1 100644 --- a/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue +++ b/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue @@ -304,7 +304,11 @@ export default { id: node?.rentContractId, }); if (state.gracePeriod) { - throw `You can't deploy on node ${node.nodeId}, its rent contract is in grace period.`; + await new Promise((_, reject) => { + setTimeout(() => { + reject(Error(`You can't deploy on node ${node.nodeId}, its rent contract is in grace period.`)); + }, 2000); + }); } } } catch (error) { diff --git a/packages/playground/src/utils/nodeSelector.ts b/packages/playground/src/utils/nodeSelector.ts index bfb4dd5b43..e4fec2653f 100644 --- a/packages/playground/src/utils/nodeSelector.ts +++ b/packages/playground/src/utils/nodeSelector.ts @@ -229,7 +229,11 @@ export async function validateRentContract( id: node.rentContractId, }); if (contractInfo.state.gracePeriod) { - throw `You can't deploy on node ${node.nodeId}, its rent contract is in grace period.`; + await new Promise((_, reject) => { + setTimeout(() => { + reject(Error(`You can't deploy on node ${node.nodeId}, its rent contract is in grace period.`)); + }, 2000); + }); } } From 053023061a9aa5cf2ce37af70ed39097608064be Mon Sep 17 00:00:00 2001 From: samaradel Date: Mon, 2 Dec 2024 15:24:54 +0200 Subject: [PATCH 6/7] Remove umwanted imports --- packages/playground/src/utils/nodeSelector.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/playground/src/utils/nodeSelector.ts b/packages/playground/src/utils/nodeSelector.ts index e4fec2653f..29528ecb97 100644 --- a/packages/playground/src/utils/nodeSelector.ts +++ b/packages/playground/src/utils/nodeSelector.ts @@ -19,7 +19,6 @@ import type { SelectionDetailsFilters, SelectionDetailsFiltersValidators, } from "../types/nodeSelector"; -import { createCustomToast, ToastType } from "./custom_toast"; import { normalizeError } from "./helpers"; export interface GetLocationsConfig { From b97790e913a6c91a97089720a447a2b1a1e186b0 Mon Sep 17 00:00:00 2001 From: samaradel Date: Sun, 15 Dec 2024 16:33:24 +0200 Subject: [PATCH 7/7] Handle console error --- .../src/components/node_selector/TfAutoNodeSelector.vue | 4 +++- packages/playground/src/utils/nodeSelector.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue b/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue index 277948ebb1..be17914bca 100644 --- a/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue +++ b/packages/playground/src/components/node_selector/TfAutoNodeSelector.vue @@ -304,11 +304,13 @@ export default { id: node?.rentContractId, }); if (state.gracePeriod) { + const err = `You can't deploy on node ${node.nodeId}, its rent contract is in grace period.`; await new Promise((_, reject) => { setTimeout(() => { - reject(Error(`You can't deploy on node ${node.nodeId}, its rent contract is in grace period.`)); + reject(Error(err)); }, 2000); }); + console.error(err); } } } catch (error) { diff --git a/packages/playground/src/utils/nodeSelector.ts b/packages/playground/src/utils/nodeSelector.ts index 29528ecb97..1229bc1457 100644 --- a/packages/playground/src/utils/nodeSelector.ts +++ b/packages/playground/src/utils/nodeSelector.ts @@ -228,11 +228,13 @@ export async function validateRentContract( id: node.rentContractId, }); if (contractInfo.state.gracePeriod) { + const err = `You can't deploy on node ${node.nodeId}, its rent contract is in grace period.`; await new Promise((_, reject) => { setTimeout(() => { - reject(Error(`You can't deploy on node ${node.nodeId}, its rent contract is in grace period.`)); + reject(Error(err)); }, 2000); }); + console.error(err); } }