@@ -29,8 +29,9 @@ import (
2929var Version = "dev"
3030
3131type ModuleConfig struct {
32- EnabledModules []string
33- DisabledModules []string
32+ EnabledModules []string
33+ DisabledModules []string
34+ ExecutionTimeout time.Duration
3435}
3536
3637type JSHandler struct {
@@ -42,7 +43,8 @@ type JSHandler struct {
4243
4344func NewJSHandler () * JSHandler {
4445 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 ,
4648 })
4749}
4850
@@ -213,8 +215,12 @@ func (h *JSHandler) handleRegularCode(ctx context.Context, code string) (*mcp.Ca
213215 consoleModule := console .NewConsoleModule (& output )
214216 consoleModule .Setup (vm .Runtime ())
215217
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 )
218224 defer cancel ()
219225
220226 // Execute in a goroutine to respect timeout
0 commit comments