Implement AsyncDisposable to support TS 5.2's using#1080
Merged
cristianrgreco merged 12 commits intomainfrom Jul 18, 2025
Merged
Implement AsyncDisposable to support TS 5.2's using#1080cristianrgreco merged 12 commits intomainfrom
AsyncDisposable to support TS 5.2's using#1080cristianrgreco merged 12 commits intomainfrom
Conversation
✅ Deploy Preview for testcontainers-node ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for TypeScript 5.2's using keyword, implementing automatic resource disposal for test containers. The changes modernize resource management by replacing manual await container.stop() calls with automatic disposal when containers go out of scope.
- Updates container and network classes to implement
AsyncDisposableinterface - Modifies test files to use
await usingfor automatic resource cleanup - Enhances helper functions to return disposable objects
Reviewed Changes
Copilot reviewed 73 out of 73 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/testcontainers/src/test-container.ts | Extends StartedTestContainer interface with AsyncDisposable |
| packages/testcontainers/src/generic-container/started-generic-container.ts | Implements Symbol.asyncDispose for containers |
| packages/testcontainers/src/network/network.ts | Implements AsyncDisposable for networks |
| packages/testcontainers/src/utils/test-helper.ts | Updates helper to return disposable event stream |
| Test files across all modules | Replace manual cleanup with await using declarations |
usingAsyncDisposable to support TS 5.2's using
joebowbeer
reviewed
Dec 18, 2025
Comment on lines
+102
to
+104
| async [Symbol.asyncDispose]() { | ||
| await this.startedTestContainer[Symbol.asyncDispose](); | ||
| } |
Contributor
There was a problem hiding this comment.
@cristianrgreco Shouldn't this call this.stop?
Suggested change
| async [Symbol.asyncDispose]() { | |
| await this.startedTestContainer[Symbol.asyncDispose](); | |
| } | |
| async [Symbol.asyncDispose]() { | |
| await this.stop(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feature info here: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management
Before:
After:
Same for
NetworkandDockerComposeEnvironment.