Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncatchable DNS errors #176

Open
MorningLightMountain713 opened this issue Aug 9, 2024 · 0 comments
Open

Uncatchable DNS errors #176

MorningLightMountain713 opened this issue Aug 9, 2024 · 0 comments

Comments

@MorningLightMountain713
Copy link

MorningLightMountain713 commented Aug 9, 2024

If a user adds a leading backslash to an image name, it causes an uncatchable DNS error to be thrown. One of ENOTFOUND, EAI_AGAIN or ESERVFAIL.

I am working around this currently by catching this globally with process.on('uncaughtException', ...) but it's ugly.

Error: (HTTP code 301) unexpected -
    at /home/davew/testDocker/node_modules/docker-modem/lib/modem.js:382:17
    at getCause (/home/davew/testDocker/node_modules/docker-modem/lib/modem.js:417:7)
    at Modem.buildPayload (/home/davew/testDocker/node_modules/docker-modem/lib/modem.js:378:5)
    at IncomingMessage.<anonymous> (/home/davew/testDocker/node_modules/docker-modem/lib/modem.js:346:16)
    at IncomingMessage.emit (node:events:526:35)
    at endReadableNT (node:internal/streams/readable:1408:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  reason: undefined,
  statusCode: 301,
  json: <Buffer >
}
node:events:492
      throw er; // Unhandled 'error' event
      ^

Error: getaddrinfo EAI_AGAIN images
    at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:118:26)
Emitted 'error' event on ClientRequest instance at:
    at Socket.socketErrorListener (node:_http_client:495:9)
    at Socket.emit (node:events:514:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -3001,
  code: 'EAI_AGAIN',
  syscall: 'getaddrinfo',
  hostname: 'images'
}

Node.js v20.9.0

Here is an MRE:

const Dockerode = require('dockerode');

const docker = new Dockerode();

async function main() {
    image = docker.getImage('/nginx:latest');
    await image.remove().catch((err) => console.log(err));

    await new Promise((r) => setTimeout(r, 3_000_000));
}

main();

Reading the docker docs, it states The path consists of slash-separated components. , which implies that they can't start or end with a slash. The easy solution here is to throw an error in Modem.prototype.dial if the path starts with a slash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant