Skip to content

at_exit hook sometimes freeze forever when a rails application executes test codes #1153

@joker1007

Description

@joker1007

Your environment

  • ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux]
  • rdbg 1.11.0

Describe the bug

This issue is related to #1113.

Since the at_exit hook waits for all child processes other than the Ruby process, it leads to the following problem in the test code of a real Rails application.

  1. Load the debug gem
  2. The capybara-playwright-driver starts Playwright as a child process
  3. The capybara-playwright-driver registers an at_exit hook to terminate Playwright when the test ends
  4. During test code execution, when a fork occurs, the debug gem registers the at_exit hook
  5. After all test cases have finished, the debug gem's at_exit hook executes first and waits for the child process to terminate, but since the at_exit hook to terminate Playwright does not execute, it continues to wait indefinitely

This can occur normally if the debug gem is required.
If it happens in a CI execution environment, it could result in unnecessary costs by holding computing resources for a long time.

I believe that waiting for all child processes(including not Ruby process) after a fork occurs is a significant issue.

To Reproduce

I described above.

Expected behavior

process finishes successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions