mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 02:04:05 +00:00
Fix REPL timeout with return statements by wrapping user code in function
- User code with return statement was exiting the async IIFE early - Completion callbacks and window.complete() were never reached - Now wrap user code in userCodeFunc to capture return value - Return statement returns from userCodeFunc, not outer IIFE - Completion callbacks and window.complete() always execute - Return value is logged to console output - Fixes 30-second timeout when using return statements in REPL
This commit is contained in:
parent
fdd4e24246
commit
9a3f01fcb8
1 changed files with 11 additions and 1 deletions
|
|
@ -328,7 +328,17 @@ export class SandboxIframe extends LitElement {
|
|||
<script type="module">
|
||||
(async () => {
|
||||
try {
|
||||
${userCode}
|
||||
// Wrap user code in async function to capture return value
|
||||
const userCodeFunc = async () => {
|
||||
${userCode}
|
||||
};
|
||||
|
||||
const returnValue = await userCodeFunc();
|
||||
|
||||
// Log return value if present
|
||||
if (returnValue !== undefined) {
|
||||
console.log('Return value:', returnValue);
|
||||
}
|
||||
|
||||
// Call completion callbacks before complete()
|
||||
if (window.__completionCallbacks && window.__completionCallbacks.length > 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue