fix unwrap causing panic (#5886)

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2025-03-19 10:19:19 -07:00
committed by GitHub
parent ddcff1ba63
commit 270f173aad
3 changed files with 22 additions and 8 deletions

View File

@ -831,8 +831,7 @@ impl ExecutorContext {
.await?; .await?;
let (module_memory, _) = self let (module_memory, _) = self
.exec_module_for_items(id, exec_state, ExecutionKind::Isolated, source_range) .exec_module_for_items(id, exec_state, ExecutionKind::Isolated, source_range)
.await .await?;
.unwrap();
exec_state.mut_stack().memory.set_std(module_memory); exec_state.mut_stack().memory.set_std(module_memory);
} }

View File

@ -9,6 +9,7 @@ import { KCLError } from 'lang/errors'
import { Diagnostic } from '@codemirror/lint' import { Diagnostic } from '@codemirror/lint'
import { Node } from '@rust/kcl-lib/bindings/Node' import { Node } from '@rust/kcl-lib/bindings/Node'
import RustContext from 'lib/rustContext' import RustContext from 'lib/rustContext'
import { EXECUTE_AST_INTERRUPT_ERROR_STRING } from 'lib/constants'
export type ToolTip = export type ToolTip =
| 'lineTo' | 'lineTo'
@ -116,10 +117,7 @@ function handleExecuteError(e: any): ExecutionResult {
let isInterrupted = false let isInterrupted = false
if (e instanceof KCLError) { if (e instanceof KCLError) {
// Detect if it is a force interrupt error which is not a KCL processing error. // Detect if it is a force interrupt error which is not a KCL processing error.
if ( if (e.msg.includes(EXECUTE_AST_INTERRUPT_ERROR_STRING)) {
e.msg ===
'Failed to wait for promise from engine: JsValue("Force interrupt, executionIsStale, new AST requested")'
) {
isInterrupted = true isInterrupted = true
} }
return { return {

View File

@ -1,3 +1,5 @@
import { Models } from '@kittycad/lib/dist/types/src'
export const APP_NAME = 'Modeling App' export const APP_NAME = 'Modeling App'
/** Search string in new project names to increment as an index */ /** Search string in new project names to increment as an index */
export const INDEX_IDENTIFIER = '$n' export const INDEX_IDENTIFIER = '$n'
@ -83,9 +85,24 @@ export const TELEMETRY_RAW_FILE_NAME = 'raw-metrics.txt'
export const PLAYWRIGHT_KEY = 'playwright' export const PLAYWRIGHT_KEY = 'playwright'
/** Custom error message to match when rejectAllModelCommands is called /** Custom error message to match when rejectAllModelCommands is called
* allows us to match if the execution of executeAst was interrupted */ * allows us to match if the execution of executeAst was interrupted
export const EXECUTE_AST_INTERRUPT_ERROR_MESSAGE = * This needs to be of type WebsocketResponse, so that we can parse it back out
* nicely on the rust side.
* */
export const EXECUTE_AST_INTERRUPT_ERROR_STRING =
'Force interrupt, executionIsStale, new AST requested' 'Force interrupt, executionIsStale, new AST requested'
const EXECUTE_AST_INTERRUPT_ERROR: Models['WebSocketResponse_type'] = {
success: false,
errors: [
{
message: EXECUTE_AST_INTERRUPT_ERROR_STRING,
error_code: 'bad_request',
},
],
}
export const EXECUTE_AST_INTERRUPT_ERROR_MESSAGE = JSON.stringify(
EXECUTE_AST_INTERRUPT_ERROR
)
/** The messages that appear for exporting toasts */ /** The messages that appear for exporting toasts */
export const EXPORT_TOAST_MESSAGES = { export const EXPORT_TOAST_MESSAGES = {