Skip to content

npm:docker-modem doesn't work (and @testcontainers/* as a result) #20255

Closed
@gflarity

Description

@gflarity

The blog post said we should report, so here we go:

I just trying to use testcontainers (@testcontainers/postgresql) with Deno when I got this strange error:

error: Error: (HTTP code 400) unexpected - starting container with non-empty request body was deprecated since API v1.22 and removed in v1.24
    at file:///Users/geoff/Library/Caches/deno/npm/registry.npmjs.org/docker-modem/3.0.8/lib/modem.js:343:17
    at getCause (file:///Users/geoff/Library/Caches/deno/npm/registry.npmjs.org/docker-modem/3.0.8/lib/modem.js:373:7)
    at Modem.buildPayload (file:///Users/geoff/Library/Caches/deno/npm/registry.npmjs.org/docker-modem/3.0.8/lib/modem.js:342:5)
    at IncomingMessageForClient.<anonymous> (file:///Users/geoff/Library/Caches/deno/npm/registry.npmjs.org/docker-modem/3.0.8/lib/modem.js:310:16)

So it seems there might be some http client compatibility issues, as the docker api is just HTTP last time I checked...

Here's the repro code which was inspired by this Testcontainer Node quickstart repo (which runs fine using node):

import { PostgreSqlContainer } from "npm:@testcontainers/postgresql";
import postgres from "https://deno.land/x/postgresjs/mod.js";

Deno.test("hello postgres", async () => {
  const initScript = `
            create table guides
            (
                id    bigserial     not null,
                title varchar(1023) not null,
                url   varchar(1023) not null,
                primary key (id)
            );

            insert into guides(title, url)
            values ('Getting started with Testcontainers',
                    'https://testcontainers.com/getting-started/'),
                   ('Getting started with Testcontainers for Java',
                    'https://testcontainers.com/guides/getting-started-with-testcontainers-for-java/'),
                   ('Getting started with Testcontainers for .NET',
                    'https://testcontainers.com/guides/getting-started-with-testcontainers-for-dotnet/'),
                   ('Getting started with Testcontainers for Node.js',
                    'https://testcontainers.com/guides/getting-started-with-testcontainers-for-nodejs/'),
                   ('Getting started with Testcontainers for Go',
                    'https://testcontainers.com/guides/getting-started-with-testcontainers-for-go/'),
                   ('Testcontainers container lifecycle management using JUnit 5',
                    'https://testcontainers.com/guides/testcontainers-container-lifecycle/')
            ;
        `;

  const container = await new PostgreSqlContainer("postgres:14-alpine",)
    .withCopyContentToContainer([
      { content: initScript, target: "/docker-entrypoint-initdb.d/init.sql" },
    ])
    .start();

  const sql = postgres(container.getConnectionUri());
  const res = await sql`select title, url from guides`;
  console.log(res);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working correctlynode compat

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions