Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for closed resources to actually close before detecting open handles #11429

Merged

Commits on May 20, 2021

  1. Don't detect async handles already queued to close

    Some types of async resources in Node.js are not destroyed until *after* their `close` or `end` or similar callbacks and events run, leading to a situation where the `--detectOpenHandles` option can falsely flag resources that have been cleaned up in user code and are already scheduled for destruction. For example, if a test ends from the callback to `TCPServer.close()` and no other tests or lifecycle functions impose additional delays, `--detectOpenHandles` will flag the server even though it has been closed. This is the main cause of issues people encounter with Supertest (see jestjs#8554).
    
    This addresses the issue by adding a short delay before collecting open handles.
    
    Depends on jestjs#11382.
    Mr0grog committed May 20, 2021
    Copy the full SHA
    0416117 View commit details
    Browse the repository at this point in the history
  2. Track indirectly created async resources

    This fixes a test that the previous commit broke. Some commands (for example, starting a TCP/HTTP server with the `host` option) can cause other async resources to be created indire
    ctly (so their stack traces don't have any user code in them). Since these are still triggered by things in a user's code, we now track and show them when `--detectOpenHandles` is used.
    
    This also increases the size of stack traces in `ErrorWithStack` because some of the Node internals in these async stack traces are deep enough that the test wrapper functions we lo
    ok for fall off the bottom of the stack trace!
    Mr0grog committed May 20, 2021
    Copy the full SHA
    0950417 View commit details
    Browse the repository at this point in the history
  3. Add changelog entry

    Mr0grog committed May 20, 2021
    Copy the full SHA
    1d650bf View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    609aa62 View commit details
    Browse the repository at this point in the history
  5. Copy the full SHA
    0fab1e4 View commit details
    Browse the repository at this point in the history
  6. PR feedback

    SimenB committed May 20, 2021
    Copy the full SHA
    f499edc View commit details
    Browse the repository at this point in the history
  7. pull in test from jestjs#11278

    SimenB committed May 20, 2021
    Copy the full SHA
    e5bd74f View commit details
    Browse the repository at this point in the history
  8. Revert "pull in test from jestjs#11278"

    This reverts commit e5bd74f.
    SimenB committed May 20, 2021
    Copy the full SHA
    2ab6387 View commit details
    Browse the repository at this point in the history
  9. Copy the full SHA
    afea019 View commit details
    Browse the repository at this point in the history