Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions packages/modules/selenium/src/selenium-container.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { copyFile } from "node:fs/promises";
import path from "node:path";
import { pipeline } from "node:stream/promises";
import tar from "tar-fs";
import {
AbstractStartedContainer,
Expand Down Expand Up @@ -140,10 +141,6 @@ export class StoppedSeleniumRecordingContainer extends StoppedSeleniumContainer
}

private async extractTarStreamToDest(tarStream: NodeJS.ReadableStream, dest: string): Promise<void> {
await new Promise<void>((resolve) => {
const destination = tar.extract(dest);
tarStream.pipe(destination);
destination.on("finish", resolve);
});
await pipeline(tarStream, tar.extract(dest));
}
}
1 change: 0 additions & 1 deletion packages/testcontainers/src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export { withFileLock } from "./file-lock";
export { hash } from "./hash";
export { buildLog, composeLog, containerLog, execLog, Logger, log, pullLog } from "./logger";
export { IntervalRetry, Retry } from "./retry";
export { streamToString } from "./streams";
export * from "./time";
export * from "./type-guards";
export { RandomUuid, randomUuid, Uuid } from "./uuid";
15 changes: 0 additions & 15 deletions packages/testcontainers/src/common/streams.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IncomingMessage } from "node:http";
import { PassThrough, Readable } from "node:stream";
import { PassThrough, type Readable } from "node:stream";
import { finished } from "node:stream/promises";
import type Dockerode from "dockerode";
import type {
Expand All @@ -11,7 +11,7 @@ import type {
ExecCreateOptions,
Network,
} from "dockerode";
import { execLog, log, streamToString, toSeconds } from "../../../common";
import { execLog, log, toSeconds } from "../../../common";
import type { CopyToContainerOptions } from "../../../types";
import type { ContainerClient } from "./container-client";
import type { ContainerCommitOptions, ContainerStatus, ExecOptions, ExecResult } from "./types";
Expand Down Expand Up @@ -83,15 +83,11 @@ export class DockerContainerClient implements ContainerClient {
): Promise<void> {
try {
log.debug(`Putting archive to container...`, { containerId: container.id });
await streamToString(
Readable.from(
await container.putArchive(stream, {
path,
noOverwriteDirNonDir: options?.noOverwriteDirNonDir,
copyUIDGID: options?.copyUIDGID,
})
)
);
await container.putArchive(stream, {
path,
noOverwriteDirNonDir: options?.noOverwriteDirNonDir,
copyUIDGID: options?.copyUIDGID,
});
log.debug(`Put archive to container`, { containerId: container.id });
} catch (err) {
log.error(`Failed to put archive to container: ${err}`, { containerId: container.id });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { text } from "node:stream/consumers";
import type Dockerode from "dockerode";
import { log, streamToString } from "../../common";
import { log } from "../../common";
import { ImageName } from "../image-name";
import { attachContainer } from "./attach-container";
import { pullImage } from "./pull-image";
Expand All @@ -24,7 +25,7 @@ export const runInContainer = async (
await startContainer(container);

log.debug(`Waiting for container output...`, { containerId: container.id });
const output = await streamToString(stream, { trim: true });
const output = (await text(stream)).trim();

log.debug(`Removing container...`, { containerId: container.id });
await container.remove({ force: true, v: true });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { text } from "node:stream/consumers";
import type Dockerode from "dockerode";
import { Agent, request } from "undici";
import { IntervalRetry, log } from "../common";
Expand Down Expand Up @@ -153,18 +154,13 @@ export class HttpWaitStrategy extends AbstractWaitStrategy {

private async handleContainerExit(container: Dockerode.Container) {
const tail = 50;
const lastLogs: string[] = [];
const client = await getContainerRuntimeClient();
let message: string;

try {
const stream = await client.container.logs(container, { tail });
const lastLogs = await text(await client.container.logs(container, { tail }));

await new Promise((res) => {
stream.on("data", (d) => lastLogs.push(d.trim())).on("end", res);
});

message = `Container exited during HTTP healthCheck, last ${tail} logs: ${lastLogs.join("\n")}`;
message = `Container exited during HTTP healthCheck, last ${tail} logs: ${lastLogs.trim()}`;
} catch (_err) {
message = "Container exited during HTTP healthCheck, failed to get last logs";
}
Expand Down
Loading