@@ -29,8 +29,9 @@ import (
29
29
var Version = "dev"
30
30
31
31
type ModuleConfig struct {
32
- EnabledModules []string
33
- DisabledModules []string
32
+ EnabledModules []string
33
+ DisabledModules []string
34
+ ExecutionTimeout time.Duration
34
35
}
35
36
36
37
type JSHandler struct {
@@ -42,7 +43,8 @@ type JSHandler struct {
42
43
43
44
func NewJSHandler () * JSHandler {
44
45
return NewJSHandlerWithConfig (ModuleConfig {
45
- EnabledModules : []string {"http" , "fetch" , "timers" , "buffer" , "kv" , "crypto" , "encoding" , "url" , "cache" },
46
+ EnabledModules : []string {"http" , "fetch" , "timers" , "buffer" , "kv" , "crypto" , "encoding" , "url" , "cache" },
47
+ ExecutionTimeout : 5 * time .Minute ,
46
48
})
47
49
}
48
50
@@ -213,8 +215,12 @@ func (h *JSHandler) handleRegularCode(ctx context.Context, code string) (*mcp.Ca
213
215
consoleModule := console .NewConsoleModule (& output )
214
216
consoleModule .Setup (vm .Runtime ())
215
217
216
- // Execute the JavaScript code with a timeout for regular code
217
- execCtx , cancel := context .WithTimeout (ctx , time .Second * 10 )
218
+ // Execute the JavaScript code with configurable timeout
219
+ timeout := h .config .ExecutionTimeout
220
+ if timeout == 0 {
221
+ timeout = 5 * time .Minute // Default fallback
222
+ }
223
+ execCtx , cancel := context .WithTimeout (ctx , timeout )
218
224
defer cancel ()
219
225
220
226
// Execute in a goroutine to respect timeout
0 commit comments