Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4570

Investigate NODE-4569 - Can not use zstd for network compression in docker.

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • 2
    • Not Needed

      NODE-4569 Description

      What problem are you facing?

      Can not use zstd for network compression in a docker.
      When I start the app on my local machine it works,
      when I start the app in the docker image it does not work.
      Error message: MongoMissingDependencyError: Optional module `@mongodb-js/zstd` not found. Please install it to enable zstd compression

      What driver and relevant dependency versions are you using?

      • "@mongodb-js/zstd": "^1.0.0"
      • "mongodb": "^4.9.0"
      • macbook pro m1 macOS Monterey 12.5.1
      • {{node -v v18.5.0-v     }}
      • npm -v 8.12.1-v  

      Steps to reproduce?

      // index.js
      const { MongoClient } = require("mongodb");
      const uri = process.env.CONNECTION_STRING + "&compressors=zstd";
      const client = new MongoClient(uri);
       
      async function main() {
        awaitclient.connect();
        constconnection=client.db().collection('entity_name');
        constresponse=awaitconnection.findOne({});
        console.log(response);
      }
       
      main().then(() => {}).catch((error) => console.log(error))
      //
       
      // package.json
      {{{}}
      "name": "mongo-db-compress-test",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1"
      },
      "keywords": [],
      "author": "",
      "license": "ISC",
      "dependencies": {
      "@mongodb-js/zstd": "^1.0.0",
      "mongodb": "^4.9.0"
      }
      }
      //
       
      npm install
       
      // local run works OK:
      CONNECTION_STRING="mongodb+srv://..." node index.js

      // Dokerfile
      FROM node:18-alpine
      WORKDIR /app
       
      COPY ./package.json ./package.json
      COPY ./index.js ./index.js
       
      RUN npm install
       
      ENV CONNECTION_STRING "mongodb+srv://..."
      ENTRYPOINT ["node", "/app/index.js"]
      //
       
      // Docker run NOT OK
      docker build -t test . && docker run -it test
       
      MongoMissingDependencyError: Optional module `@mongodb-js/zstd` not found. Please install it to enable zstd compression
      at Object.<anonymous> (/app/node_modules/mongodb/lib/deps.js:27:37)
      at Module._compile (node:internal/modules/cjs/loader:1120:14)
      at Module._extensions..js (node:internal/modules/cjs/loader:1174:10)
      at Module.load (node:internal/modules/cjs/loader:998:32)
      at Module._load (node:internal/modules/cjs/loader:839:12)
      at Module.require (node:internal/modules/cjs/loader:1022:19)
      at require (node:internal/modules/cjs/helpers:102:18)
      at Object.<anonymous> (/app/node_modules/mongodb/lib/cmap/auth/gssapi.js:5:16)
      at Module._compile (node:internal/modules/cjs/loader:1120:14)
      at Module._extensions..js (node:internal/modules/cjs/loader:1174:10) {
      [Symbol(errorLabels)]: Set(0) {}
      }
       
       
       

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            dbeng-pm-bot PM Bot
            Durran Jordan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: