-
Type: Task
-
Resolution: Won't Fix
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
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"
- related to
-
NODE-5184 Uncaught TypeError in mongo_types.ts
- Closed