Skip to content

Commit

Permalink
fix: handle error and fix rendering bug (#1617)
Browse files Browse the repository at this point in the history
## Description:
Added logic to handle error when script fails to run and returns an
error. Before the status of the execution would just hang as being in
progress, but now it updates the status to be an error (when the error
is returned from the EM API).

As a followup I've created issue #1618 to provide better error reporting
in the UI.

## Is this change user facing?
YES

## References (if applicable):
Closes: #1587
  • Loading branch information
adschwartz committed Oct 25, 2023
1 parent 3fa6d2f commit 825fd22
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion engine/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion engine/frontend/src/App.js
Expand Up @@ -3,7 +3,7 @@ import Home from './component/Home';
import { ChakraProvider } from '@chakra-ui/react'

const App = () => {
console.log("Enclave Manager version: 2023-10-18-01")
console.log("Enclave Manager version: 2023-10-25-01")
return (
<ChakraProvider>
<div className="h-screen w-screen bg-[#171923]">
Expand Down
3 changes: 2 additions & 1 deletion engine/frontend/src/component/log/CreateEnclaveLog.js
Expand Up @@ -83,7 +83,6 @@ export const CreateEnclaveLog = ({packageId, enclave, args, appData}) => {
}

const readStreamData = (result) => {
// console.log(`${result.case} ${JSON.stringify(result.value)}`)
if (result.case === INSTRUCTION) {
setLogs(logs => [...logs, result.value.executableInstruction])
}
Expand Down Expand Up @@ -145,6 +144,8 @@ export const CreateEnclaveLog = ({packageId, enclave, args, appData}) => {
}
} catch (ex) {
console.error("Error occurred while reading data from the enclave: ", enclave.name)
setLogsExecutionStatusText("Script failed to run with an error")
setLogsCurrentExecutionStatus(logsStatus(SCRIPT_RUN_STATUS_ERROR, null))
} finally {
setLoading(false)
}
Expand Down
4 changes: 1 addition & 3 deletions engine/frontend/src/component/log/Log.js
Expand Up @@ -31,15 +31,13 @@ export const Log = ({logs, fileName, currentExecutionStatus, executionStatusText
const virtuosoRef = useRef(null)
const {height: windowHeight} = useWindowDimensions();
const {onCopy, setValue: setCopyValue, hasCopied} = useClipboard("");
const [logsExecutionStatus, setLogsExecutionStatus] = useState(<></>)

useEffect(() => {
setDisplayLogs(logs);
const logsWithoutAnsi = logs.map((log) => {
return stripAnsi(log)
})
setCopyValue(logsWithoutAnsi.join(os.EOL))
setLogsExecutionStatus(currentExecutionStatus)
}, [logs]);

const handleDownload = () => {
Expand Down Expand Up @@ -82,7 +80,7 @@ export const Log = ({logs, fileName, currentExecutionStatus, executionStatusText
<Box p='2' m="4"
height={"40px"}
>
{logsExecutionStatus}
{currentExecutionStatus}
</Box>
<Tooltip label={`${hasCopied ? "Copied!" : "Copy to clipboard"}`}
placement='top-end'
Expand Down
6 changes: 3 additions & 3 deletions engine/server/webapp/asset-manifest.json
@@ -1,13 +1,13 @@
{
"files": {
"main.css": "./static/css/main.2cce5778.css",
"main.js": "./static/js/main.7c3e575c.js",
"main.js": "./static/js/main.bdecb19c.js",
"index.html": "./index.html",
"main.2cce5778.css.map": "./static/css/main.2cce5778.css.map",
"main.7c3e575c.js.map": "./static/js/main.7c3e575c.js.map"
"main.bdecb19c.js.map": "./static/js/main.bdecb19c.js.map"
},
"entrypoints": [
"static/css/main.2cce5778.css",
"static/js/main.7c3e575c.js"
"static/js/main.bdecb19c.js"
]
}
2 changes: 1 addition & 1 deletion engine/server/webapp/index.html
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>Kurtosis Enclave Manager</title><script defer="defer" src="./static/js/main.7c3e575c.js"></script><link href="./static/css/main.2cce5778.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>Kurtosis Enclave Manager</title><script defer="defer" src="./static/js/main.bdecb19c.js"></script><link href="./static/css/main.2cce5778.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 825fd22

Please sign in to comment.