-
-
Notifications
You must be signed in to change notification settings - Fork 754
nock@14 breaks testcontainers #2839
Copy link
Copy link
Closed
Labels
Description
Please avoid duplicates
- I checked all open bugs and none of them matched my problem.
Reproducible test case
Nock Version
14.0.0
Node Version
22.13.1
TypeScript Version
No response
What happened?
I updated to nock@14 and suddenly testcontainers stopped working.
Code in gist shows case which works:
radek@olive:~/nock-testcontainers-test$ node index.mjs
Container started
Container stoppedBut when nock is imported (without any changes, because according to the docs by default it allows access) testcontainers fails.
radek@olive:~/nock-testcontainers-test$ head -n4 index.mjs
import { GenericContainer } from 'testcontainers';
// uncomment next line to see bug
import nock from 'nock';
radek@olive:~/nock-testcontainers-test$ DEBUG=testcontainers node index.mjs
testcontainers [DEBUG] Checking container runtime strategy "TestcontainersHostStrategy"... +0ms
testcontainers [DEBUG] Container runtime strategy "TestcontainersHostStrategy" is not applicable +3ms
testcontainers [DEBUG] Checking container runtime strategy "ConfigurationStrategy"... +0ms
testcontainers [DEBUG] Container runtime strategy "ConfigurationStrategy" is not applicable +0ms
testcontainers [DEBUG] Checking container runtime strategy "UnixSocketStrategy"... +0ms
testcontainers [TRACE] Fetching Docker info... +1ms
testcontainers [DEBUG] Container runtime strategy "UnixSocketStrategy" does not work: "Error: connect ECONNREFUSED 127.0.0.1:80" +37ms
testcontainers [DEBUG] Error: connect ECONNREFUSED 127.0.0.1:80
testcontainers at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1634:16) +0ms
testcontainers [DEBUG] Checking container runtime strategy "RootlessUnixSocketStrategy"... +1ms
testcontainers [DEBUG] Container runtime strategy "RootlessUnixSocketStrategy" is not applicable +1ms
testcontainers [DEBUG] Checking container runtime strategy "NpipeSocketStrategy"... +0ms
testcontainers [DEBUG] Container runtime strategy "NpipeSocketStrategy" is not applicable +0ms
/home/radek/nock-testcontainers-test/node_modules/testcontainers/build/container-runtime/clients/client.js:66
throw new Error("Could not find a working container runtime strategy");
^
Error: Could not find a working container runtime strategy
at getContainerRuntimeClient (/home/radek/nock-testcontainers-test/node_modules/testcontainers/build/container-runtime/clients/client.js:66:11)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async GenericContainer.start (/home/radek/nock-testcontainers-test/node_modules/testcontainers/build/generic-container/generic-container.js:55:24)
at async file:///home/radek/nock-testcontainers-test/index.mjs:8:26
Node.js v22.13.1As you see, it cannot connect to the socket:
testcontainers [DEBUG] Container runtime strategy "UnixSocketStrategy" does not work: "Error: connect ECONNREFUSED 127.0.0.1:80" +37ms
testcontainers [DEBUG] Error: connect ECONNREFUSED 127.0.0.1:80
radek@olive:~/nock-testcontainers-test$ docker context ls
NAME DESCRIPTION DOCKER ENDPOINT ERROR
default * Current DOCKER_HOST based configuration unix:///var/run/docker.sockDowngrading to [email protected] fixes the issue:
# npm install nock@13
radek@olive:~/nock-testcontainers-test$ npm ls nock
[email protected] /home/radek/nock-testcontainers-test
└── [email protected]
radek@olive:~/nock-testcontainers-test$ head -n 4 index.mjs
import { GenericContainer } from 'testcontainers';
// uncomment next line to see bug
import nock from 'nock';
radek@olive:~/nock-testcontainers-test$ node index.mjs
Container started
Container stoppedAm I doing something incorrectly? Is there additional configuration required?
Would you be interested in contributing a fix?
- yes
Reactions are currently unavailable