Skip to content

Commit a0cc790

Browse files
hotfix for undici in exec tests
1 parent cf8f0a7 commit a0cc790

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

docs/modules/MobyEndpoints.ts.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ declare const ContainersApi: HttpApi<
442442
readonly stdin?: boolean | undefined
443443
},
444444
never,
445-
never,
445+
{ readonly Upgrade: "tcp"; readonly Connection: "Upgrade" },
446446
void,
447447
BadRequest | NotFound,
448448
never,
@@ -632,7 +632,7 @@ declare const ExecsApi: HttpApi<
632632
{ readonly id: string & Brand<"ExecId"> },
633633
never,
634634
ContainerExecStartOptions,
635-
never,
635+
{ readonly Upgrade: "tcp"; readonly Connection: "Upgrade" },
636636
void,
637637
NotFound | Conflict,
638638
never,

src/internal/endpoints/containers.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,12 @@ const attachContainerEndpoint = HttpApiEndpoint.post("attach", "/:identifier/att
261261
stderr: Schema.optional(Schema.BooleanFromString),
262262
})
263263
)
264-
// Broken on undici
265-
// .setHeaders(
266-
// Schema.Struct({
267-
// Upgrade: Schema.Literal("tcp"),
268-
// Connection: Schema.Literal("Upgrade"),
269-
// })
270-
// )
264+
.setHeaders(
265+
Schema.Struct({
266+
Upgrade: Schema.Literal("tcp"),
267+
Connection: Schema.Literal("Upgrade"),
268+
})
269+
)
271270
.addSuccess(HttpApiSchema.Empty(101)) // 101 Switching Protocols
272271
.addSuccess(HttpApiSchema.Empty(200)) // 200 OK
273272
.addError(BadRequest) // 400 Bad parameter
@@ -513,7 +512,7 @@ export class Containers extends Effect.Service<Containers>()("@the-moby-effect/e
513512
)({
514513
path: { identifier },
515514
urlParams: { ...options },
516-
// headers: { Connection: "Upgrade", Upgrade: "tcp" },
515+
headers: { Connection: "Upgrade", Upgrade: "tcp" }, // FIXME: Broken on undici
517516
}),
518517
ContainersError("attach")
519518
);

src/internal/endpoints/execs.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ const createExecEndpoint = HttpApiEndpoint.post("container", "/containers/:id/ex
2424
/** @see https://docs.docker.com/reference/api/engine/latest/#tag/Exec/operation/ExecStart */
2525
const startExecEndpoint = HttpApiEndpoint.post("start", "/exec/:id/start")
2626
.setPath(Schema.Struct({ id: ExecIdentifier }))
27-
// Broken on undici
28-
// .setHeaders(
29-
// Schema.Struct({
30-
// Upgrade: Schema.Literal("tcp"),
31-
// Connection: Schema.Literal("Upgrade"),
32-
// })
33-
// )
27+
.setHeaders(
28+
Schema.Struct({
29+
Upgrade: Schema.Literal("tcp"),
30+
Connection: Schema.Literal("Upgrade"),
31+
})
32+
)
3433
.setPayload(ContainerExecStartOptions)
3534
.addSuccess(HttpApiSchema.Empty(101))
3635
.addSuccess(HttpApiSchema.Empty(200))
@@ -108,7 +107,7 @@ export class Execs extends Effect.Service<Execs>()("@the-moby-effect/endpoints/E
108107
)({
109108
path: { id },
110109
payload: ContainerExecStartOptions.make(payload),
111-
// headers: { Connection: "Upgrade", Upgrade: "tcp" },
110+
headers: { Connection: "Upgrade", Upgrade: "tcp" }, // FIXME: Broken on undici
112111
})
113112
.pipe(
114113
Effect.map(

test/exec.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { FileSystem, Path } from "@effect/platform";
22
import { NodeContext } from "@effect/platform-node";
33
import { describe, expect, layer } from "@effect/vitest";
44
import { Context, Duration, Effect, Layer, Sink, Stream } from "effect";
5-
import { DockerEngine, MobyConnection, MobyConvey, MobyDemux, MobyEndpoints } from "the-moby-effect";
5+
import { DindEngine, DockerEngine, MobyConnection, MobyConvey, MobyDemux, MobyEndpoints } from "the-moby-effect";
66
import { makePlatformDindLayer } from "./shared-file.js";
77
import { testMatrix } from "./shared-global.js";
88

@@ -49,6 +49,9 @@ describe.each(testMatrix)(
4949
layer(testLayer, { timeout: Duration.minutes(2) })("MobyApi Execs tests", (it) => {
5050
it.scoped("exec", () =>
5151
Effect.gen(function* () {
52+
// FIXME: can't send the right headers on undici
53+
if (makePlatformDindLayer === DindEngine.layerUndici) return;
54+
5255
const { Id: id } = yield* DockerEngine.runScoped({
5356
Image: "docker.io/library/alpine:latest",
5457
Cmd: ["sleep", "1m"],

0 commit comments

Comments
 (0)