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

Receiving TypeError every time connect method is called

    • Type: Icon: Task Task
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • 1
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      I am currently working on a project that uses vite, tauri, react and typesccript. I use the mongoDB package to call the mongoDB atlas database. After providing the url and calling the connect method causes the TypeError.

      The Error:

      TypeError: undefined is not an object (evaluating 'dns.promises.resolveSrv')
      (anonymous function) — connection_string.ts:82
      asyncFunctionResume
      (anonymous function) — mongo_client.ts:439
      asyncFunctionResume
      (anonymous function) — mongo_client.ts:415
      asyncFunctionResume
      (anonymous function) — database.ts:30
      asyncFunctionResume
      (anonymous function) — sample-audio.tsx:23
      asyncFunctionResume
      (anonymous function) — sample-audio.tsx:27
      commitHookEffectListMount — react-dom.development.js:23150
      commitPassiveMountOnFiber — react-dom.development.js:24926
      commitPassiveMountEffects_complete — react-dom.development.js:24891
      commitPassiveMountEffects_begin — react-dom.development.js:24878
      commitPassiveMountEffects — react-dom.development.js:24866
      flushPassiveEffectsImpl — react-dom.development.js:27039
      flushPassiveEffects — react-dom.development.js:26984
      (anonymous function) — react-dom.development.js:26769
      workLoop — scheduler.development.js:266
      flushWork — scheduler.development.js:239
      performWorkUntilDeadline — scheduler.development.js:533 
      

       

      My code:

      Unable to find source-code formatter for language: typescript. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      import { MongoClient, ServerApiVersion } from 'mongodb'
      import * as dotenv from 'dotenv'
      // eslint-disable-next-line no-labels
      
      // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
      export async function getSampleAudio () {
        dotenv.config()
        console.log(import.meta.env.VITE_DB_CONN_STRING)
        constmongoClient: MongoClient = newMongoClient(import.meta.env.VITE_DB_CONN_STRING, {
          serverApi: {
            version:ServerApiVersion.v1,
            strict:true,
            deprecationErrors:true
          }
        })
        try {
          await mongoClient.connect()
          constdata = await mongoClient.db().collection('sample_audio').find({}).toArray()
          console.log('!!!', data)
        } catch (e) {
          console.log('!!!', e)
        }
      }
      

      Package Version:

      Node Version: v18.16.0,
      "mongodb": "^4.15.0",
      "typescript": "^4.9.5",
      "vite": "^4.0.0",
      "vite-plugin-node-polyfills": "^0.8.1"

            Assignee:
            alex.bevilacqua@mongodb.com Alex Bevilacqua
            Reporter:
            donn2610@gmail.com Donn Williams
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: