Skip to content

Debugee exit code not correctly reported during event_exited #475

Description

I am having an issue where the exit code of the debugee is reported as 0 instead of 1 when event_exited completes (fires back), when the debugee exits the session. I am using the latest version of this extension and I am using the following dap plugin in neovim https://github.com/mfussenegger/nvim-dap. I did report the issue first there but the maintiner considers this to be an issue within the actual implementation.

Environment
  • Operating System: WSL
  • JDK version: 19
Steps To Reproduce

Initially reported here - mfussenegger/nvim-dap#886
Sample project for reproduction - sample.zip

 .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.7.1)

2023-03-05 08:59:45.792  INFO 5600 --- [           main] com.shit.TestApplication                 : Starting TestApplication using Java 19.0.1 on Asmodeus with PID 5600 (/h
ome/asmodeus/.projects/terere/target/classes started by asmodeus in /home/asmodeus/.projects/terere)
2023-03-05 08:59:45.794  INFO 5600 --- [           main] com.shit.TestApplication                 : No active profile set, falling back to 1 default profile: "default"
2023-03-05 08:59:46.418  INFO 5600 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configura
tion mode
2023-03-05 08:59:46.420  INFO 5600 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-03-05 08:59:46.430  INFO 5600 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 4 ms. Found 0 JPA repository
 interfaces.
2023-03-05 08:59:46.468  INFO 5600 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configura
tion mode
2023-03-05 08:59:46.468  INFO 5600 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data MongoDB repositories in DEFAULT mode.
2023-03-05 08:59:46.469  INFO 5600 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 0 ms. Found 0 MongoDB reposi
tory interfaces.
2023-03-05 08:59:46.482  INFO 5600 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configura
tion mode
2023-03-05 08:59:46.483  INFO 5600 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2023-03-05 08:59:46.489  INFO 5600 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 0 ms. Found 0 Redis reposito
ry interfaces.
2023-03-05 08:59:46.743  INFO 5600 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=a07847a1-12f3-3597-b28d-50072cc2df75
2023-03-05 08:59:47.126  INFO 5600 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2023-03-05 08:59:47.136  INFO 5600 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-03-05 08:59:47.137  INFO 5600 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.64]
2023-03-05 08:59:47.226  INFO 5600 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-03-05 08:59:47.227  INFO 5600 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1381 ms
2023-03-05 08:59:47.508  WARN 5600 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh
 attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resour
ce [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseI
nitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resou
rce [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframewor
k.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springf
ramework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2023-03-05 08:59:47.523  INFO 5600 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2023-03-05 08:59:47.539  INFO 5600 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-03-05 08:59:47.555 ERROR 5600 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class


Action:

Consider the following:
        If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
        If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).


[Process exited 1]
{
exitCode = 0,
type = "exited"
}
Current Result

Exit code is 0

Expected Result

Exit code is 1

Additional Information

None

Activity

  1. testforstephen commented on Mar 7, 2023

    @testforstephen
    Contributor

    The exited event is an internal DAP event, and not supposed to be used by end user. I'm wondering how this affects the user experience?

  2. asmodeus812 commented on Mar 7, 2023

    @asmodeus812
    Author

    Hmm, that is strange, what do you mean by internal ? My use case is very much dependent on the exit code, for example i would like to keep the console / terminal stdout/stderr open when the exit code is 1 and simply close it if it is 0 since i don't want / care for the output in that case (for example). Note that i am already using this approach with other adapters - such as codelldb and lldb for example which pickup the exit code correctly.

  3. testforstephen commented on Mar 14, 2023

    @testforstephen
    Contributor

    what do you mean by internal ?

    The event is a payload that's used between DA Client and DA, not exposed to external. That's why I'm asking how you monitor it in your use case.

  4. asmodeus812 commented on Mar 14, 2023

    @asmodeus812
    Author

    As i mentioned in the op, i am using https://github.com/mfussenegger/nvim-dap. That is the debug client which communicates with with the debugger, and the use case i presented above - i would like to use the exit status of the debugee to control the user interface of the editor. Mathias Fußenegger (@mfussenegger) not sure if this is a valid case ?

  5. mfussenegger commented on Mar 14, 2023

    @mfussenegger
    Contributor

    The event is a payload that's used between DA Client and DA, not exposed to external. That's why I'm asking how you monitor it in your use case.

    nvim-dap allows users to subscribe to the events to run arbitrary custom logic. The specification itself doesn't put any restrictions on how clients might use the data.

    Looks like the exit value is currently hard-coded to 0

    Could the VirtualMachine#process#exitValue be used to retrieve the actual exit value?

  6. testforstephen commented on Mar 17, 2023

    @testforstephen
    Contributor

    Could the VirtualMachine#process#exitValue be used to retrieve the actual exit value?

    Yes, this is the right place to correct the exit value.

  7. github-actions commented on Nov 14, 2025

    @github-actions

    Hi Svetlozar Iliev (@asmodeus812), I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.

    Suggestions to diagnose and work around this issue:

    • Enable verbose logging of the Java Debug Adapter to confirm whether it ever emits a non-zero exit code:

      1. In your DAP launch configuration, add trace = "verbose".
      2. Inspect the adapter messages for an event exited payload (should include body.exitCode).
    • If the exitCode is always reported as 0 in the logs, this is a bug in the Java Debug Adapter; please open an issue in the vscode-java-debug repo and include:
      • Your sample project ([sample.zip]) and DAP logs (with trace = "verbose").
      • Your DAP client (nvim-dap) version and the adapter version.

    • As a temporary workaround, you can explicitly print the exit code in your Java application (e.g. System.exit(1);) and capture it via your DAP client’s process listener if supported.

    The team will respond to your issue shortly. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or incorrect, please give it a 👎. Your feedback helps us improve!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions