From ea8da94ce9c6b22cfb0acbd6ce2b05d97ea9b40c Mon Sep 17 00:00:00 2001 From: Murat Dzhulkuttiev Date: Sun, 1 Feb 2026 22:53:03 +0300 Subject: [PATCH 1/2] fix(client): circular function call leads to memory leak --- client/src/components/DynamicJsonForm.tsx | 6 ++++++ client/src/components/ToolsTab.tsx | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/client/src/components/DynamicJsonForm.tsx b/client/src/components/DynamicJsonForm.tsx index 2f38da29e..ecd150f22 100644 --- a/client/src/components/DynamicJsonForm.tsx +++ b/client/src/components/DynamicJsonForm.tsx @@ -28,6 +28,7 @@ interface DynamicJsonFormProps { export interface DynamicJsonFormRef { validateJson: () => { isValid: boolean; error: string | null }; + hasJsonError: () => boolean; } const isTypeSupported = ( @@ -129,6 +130,10 @@ const DynamicJsonForm = forwardRef( // on every keystroke which would be inefficient and error-prone const timeoutRef = useRef>(); + const hasJsonError = () => { + return !!jsonError; + }; + // Debounce JSON parsing and parent updates to handle typing gracefully const debouncedUpdateParent = useCallback( (jsonString: string) => { @@ -253,6 +258,7 @@ const DynamicJsonForm = forwardRef( useImperativeHandle(ref, () => ({ validateJson, + hasJsonError, })); const renderFormFields = ( diff --git a/client/src/components/ToolsTab.tsx b/client/src/components/ToolsTab.tsx index d872e6299..d4bdfd19f 100644 --- a/client/src/components/ToolsTab.tsx +++ b/client/src/components/ToolsTab.tsx @@ -104,7 +104,7 @@ const ToolsTab = ({ // Function to check if any form has validation errors const checkValidationErrors = () => { const errors = Object.values(formRefs.current).some( - (ref) => ref && !ref.validateJson().isValid, + (ref) => ref && ref.hasJsonError(), ); setHasValidationErrors(errors); return errors; From fb822598eefabf6d04b61d14e23960764482d3b4 Mon Sep 17 00:00:00 2001 From: Murat Dzhulkuttiev Date: Sun, 1 Feb 2026 23:56:52 +0300 Subject: [PATCH 2/2] allow children validation --- client/src/components/ToolsTab.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/src/components/ToolsTab.tsx b/client/src/components/ToolsTab.tsx index d4bdfd19f..9e1b5d56b 100644 --- a/client/src/components/ToolsTab.tsx +++ b/client/src/components/ToolsTab.tsx @@ -102,9 +102,11 @@ const ToolsTab = ({ const { copied, setCopied } = useCopy(); // Function to check if any form has validation errors - const checkValidationErrors = () => { + const checkValidationErrors = (validateChildren: boolean = false) => { const errors = Object.values(formRefs.current).some( - (ref) => ref && ref.hasJsonError(), + (ref) => + ref && + (validateChildren ? !ref.validateJson().isValid : ref.hasJsonError()), ); setHasValidationErrors(errors); return errors; @@ -675,7 +677,7 @@ const ToolsTab = ({