Bugfix - JS function "execute" from node crashing the frontend and response is hidden (#2589)

* Bugfix - Fix crash when executing JS function from node and fix hidden response

* add toString() to code executed result

* Change height of CodeEditor to make it bigger, but still make the result visible below.

---------

Co-authored-by: Henry Heng <henryheng@flowiseai.com>
This commit is contained in:
Daniel D'Abate
2024-06-06 15:17:35 +02:00
committed by GitHub
parent 5899e50c54
commit cb93d9d557
@@ -78,7 +78,7 @@ const ExpandTextDialog = ({ show, dialogProps, onCancel, onConfirm }) => {
useEffect(() => { useEffect(() => {
if (executeCustomFunctionNodeApi.error) { if (executeCustomFunctionNodeApi.error) {
if (typeof executeCustomFunctionNodeApi.error === 'object' && executeCustomFunctionNodeApi.error?.response?.data) { if (typeof executeCustomFunctionNodeApi.error === 'object' && executeCustomFunctionNodeApi.error?.response?.data) {
setCodeExecutedResult(executeCustomFunctionNodeApi.error?.response?.data) setCodeExecutedResult(JSON.stringify(executeCustomFunctionNodeApi.error?.response?.data, null, 2))
} else if (typeof executeCustomFunctionNodeApi.error === 'string') { } else if (typeof executeCustomFunctionNodeApi.error === 'string') {
setCodeExecutedResult(executeCustomFunctionNodeApi.error) setCodeExecutedResult(executeCustomFunctionNodeApi.error)
} }
@@ -100,7 +100,7 @@ const ExpandTextDialog = ({ show, dialogProps, onCancel, onConfirm }) => {
borderColor: theme.palette.grey['500'], borderColor: theme.palette.grey['500'],
borderRadius: '12px', borderRadius: '12px',
height: '100%', height: '100%',
maxHeight: languageType === 'js' ? 'calc(100vh - 250px)' : 'calc(100vh - 220px)', maxHeight: languageType === 'js' ? 'calc(100vh - 330px)' : 'calc(100vh - 220px)',
overflowX: 'hidden', overflowX: 'hidden',
backgroundColor: 'white' backgroundColor: 'white'
}} }}
@@ -108,7 +108,7 @@ const ExpandTextDialog = ({ show, dialogProps, onCancel, onConfirm }) => {
<CodeEditor <CodeEditor
disabled={dialogProps.disabled} disabled={dialogProps.disabled}
value={inputValue} value={inputValue}
height={languageType === 'js' ? 'calc(100vh - 250px)' : 'calc(100vh - 220px)'} height={languageType === 'js' ? 'calc(100vh - 330px)' : 'calc(100vh - 220px)'}
theme={customization.isDarkMode ? 'dark' : 'light'} theme={customization.isDarkMode ? 'dark' : 'light'}
lang={languageType} lang={languageType}
placeholder={inputParam.placeholder} placeholder={inputParam.placeholder}
@@ -152,7 +152,7 @@ const ExpandTextDialog = ({ show, dialogProps, onCancel, onConfirm }) => {
<div style={{ marginTop: '15px' }}> <div style={{ marginTop: '15px' }}>
<CodeEditor <CodeEditor
disabled={true} disabled={true}
value={codeExecutedResult} value={codeExecutedResult.toString()}
height='max-content' height='max-content'
theme={customization.isDarkMode ? 'dark' : 'light'} theme={customization.isDarkMode ? 'dark' : 'light'}
lang={'js'} lang={'js'}