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
2 changes: 2 additions & 0 deletions apps/dokploy/__test__/auth/better-auth-schema-compat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,7 @@ describe("Better Auth schema compatibility", () => {
Promise.resolve(context.checkSchema?.()),
).resolves.toBeUndefined();
},
// The first case imports lib/auth and its whole module graph from scratch.
60_000,
);
});
17 changes: 10 additions & 7 deletions apps/dokploy/__test__/backup/backup-failure-output.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,20 @@ fi
};
};

const expectBackupCalls = (calls: string[], after: string[] = []) => {
expect(calls).toHaveLength(3 + after.length);
expect(calls[0]).toBe("docker ps");
// Both sides of the dump | upload pipeline start concurrently, so their order varies.
expect(calls.slice(1, 3).sort()).toEqual(["docker exec", "rclone rcat"]);
expect(calls.slice(3)).toEqual(after);
};

describe("backup script", () => {
it("dumps the database and uploads it once", () => {
const { calls, log, result } = runBackupScript(0);

expect(result.status).toBe(0);
expect(calls).toEqual(["docker ps", "docker exec", "rclone rcat"]);
expectBackupCalls(calls);
expect(log).toContain("✅ Backup uploaded to S3 successfully");
expect(log).toContain("Backup done ✅");
});
Expand All @@ -147,12 +155,7 @@ describe("backup script", () => {
const { calls, log, result } = runBackupScript(1);

expect(result.status).toBe(1);
expect(calls).toEqual([
"docker ps",
"docker exec",
"rclone rcat",
"rclone deletefile",
]);
expectBackupCalls(calls, ["rclone deletefile"]);
expect(log).toContain("❌ Error: Backup failed");
expect(log).not.toContain("SignatureDoesNotMatch");
expect(log).not.toContain("leaked-secret");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ type QueueApp = {
let missingConfigApp: QueueApp;
let configuredApp: QueueApp;

// Each import below loads the whole API module graph from a fresh registry,
// which alone can take several seconds on a busy runner.
beforeAll(async () => {
vi.resetModules();
vi.stubEnv("INNGEST_BASE_URL", "https://inngest.example");
Expand All @@ -64,7 +66,7 @@ beforeAll(async () => {
vi.resetModules();
vi.stubEnv("INNGEST_SIGNING_KEY", "signing-key");
configuredApp = (await import("../../../api/src/index")).app;
});
}, 60_000);

afterAll(() => {
vi.unstubAllEnvs();
Expand Down
12 changes: 12 additions & 0 deletions apps/dokploy/__test__/utils/remote-stream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ describe("pipeBetweenServers", () => {
).rejects.toThrow("target exited with code 3: boom");
});

it("drains the source when the target exits before reading it", async () => {
const size = 1024 * 1024;
const bytes = await pipeBetweenServers({
source: {
serverId: null,
command: `sleep 0.1; head -c ${size} /dev/zero`,
},
target: { serverId: null, command: "exit 0" },
});
expect(bytes).toBe(size);
});

it("reports a source failure", async () => {
await expect(
pipeBetweenServers({
Expand Down
33 changes: 24 additions & 9 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"dotenv": "16.6.1",
"esbuild": "0.28.2",
"lint-staged": "^15.5.2",
"node-gyp": "13.1.0",
"tsx": "4.23.15"
},
"packageManager": "bun@1.4.2",
Expand Down
8 changes: 8 additions & 0 deletions packages/server/src/utils/process/remoteStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,16 @@ export const pipeBetweenServers = async ({
onProgress?.(bytes);
});
from.stdout.pipe(to.stdin);
// pipe() pauses the source when the target's stdin closes early; a paused
// stdout never reaches EOF, so the source would never report its exit.
const drainSource = () => {
from.stdout.unpipe(to.stdin);
from.stdout.resume();
};
to.stdin.once("close", drainSource);

const targetExit = to.exit.then((code) => {
drainSource();
if (code !== 0) from.close();
return code;
});
Expand Down
Loading