oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.28k stars 1.63k forks source link

Add option to set a timeout for suspended debugger sessions #8166

Closed KaminskiDaniel0 closed 1 week ago

KaminskiDaniel0 commented 8 months ago

Problem formulation

When using the chrome inspector to debug the evaluation of a Source in a Context with the property "inspect.Suspend" set to "true" the evaluation will wait indefinitely if the inspector is not closed or the debugging process terminated. Setting sandbox options like "sandbox.MaxCPUTime" does not work around this issue because suspending the debugger in the thread means it does not use up CPU time.

Possible solution Setting a dedicated timeout for suspended evaluations regardless of any resource usage parameters as discussed in this Slack-Thread would be very helpful.

Profiteers Developers of applications that enable their users to run their own custom code in a dedicated environment would benefit greatly from this option because it enables them to easily control debugging sessions and protect their application from too many idling debuggers.

Alternative solution An alternative but more complicated approach is also discussed in this Slack-Thread. One could intercept the inspector messages and manually close it.

entlicher commented 3 months ago

@KaminskiDaniel0 what is the intended behavior after the new debugger-specific timeout expires? Is canceling of the debugger session enough? Or would you expect also an automatic termination of the application together with the debugger detach?

KaminskiDaniel0 commented 3 months ago

@entlicher I would expect the debugger to be detached and the context execution to resume and complete normally. That way we do not lose any results by accidentally forgetting to resume the debugging-session and such.

entlicher commented 1 week ago

This is fixed by https://github.com/oracle/graal/commit/e1f81a946c5b83c960bbea847f06a0cc52731927.