2017-05-24 4 views
4

mongodb 백엔드에서 Azure Cosmos DB를 사용하고 있습니다. 이 오류가 계속 발생합니다.Azure Cosmos DB : TypeError : 정의되지 않은 'electionId'속성을 읽을 수 없습니다.

Exception has occurred: Error 
TypeError: Cannot read property 'electionId' of undefined 
at ReplSetState.update (c:\dev\3dshoppers.backend\node_modules\mongodb-core\lib\topologies\replset_state.js:371:70) 
at Server._handleEvent (c:\dev\3dshoppers.backend\node_modules\mongodb-core\lib\topologies\replset.js:421:45) 
at Server.g (events.js:291:16) 
at emitOne (events.js:96:13) 
at Server.emit (events.js:188:7) 
at c:\dev\3dshoppers.backend\node_modules\mongodb-core\lib\topologies\server.js:297:14 
at c:\dev\3dshoppers.backend\node_modules\mongodb-core\lib\connection\pool.js:457:18 
at _combinedTickCallback (internal/process/next_tick.js:73:7) 
at process._tickCallback (internal/process/next_tick.js:104:9) 

저는 [email protected]를 사용하고 있습니다. npm 패키지를 최신 버전으로 업데이트하면 다른 오류가 발생합니다 ('MongoError : pool destroyed'). Cosmos DB에 문제가 있다고 생각합니다 ......

replset_state.js의이 줄에서 일어나는 일입니다.

var currentElectionId = self.set[self.primary.name.toLowerCase()].electionId; 

편집 : 아래의 두 파일로 버그를 재현 할 수있었습니다.

server.js

// packages 
const express = require('express'); 
const http = require('http'); 
const MongoClient = require('mongodb').MongoClient; 

// express app 
const app = express(); 
// mongodb 
const mongoConnectionString = process.env.MONGODB_CONNECTION_STRING; 
const mongoOptions = 
{ 
    connectTimeoutMS: 0 
} 

var mongoDB; 
var myCollection; 

MongoClient.connect(mongoConnectionString, (err, db) => { 

    if (err) throw err; 

    mongoDB = db.db('testdb'); 

    mongoDB.collection('cars', (err, collection) => {    
      if (err) throw err;    
      myCollection = collection; 
     }); 

     http.createServer(app).listen(process.env.PORT || 3000); 
}); 

package.json

{ 
    "name": "mongodb-debug", 
    "description": "mongodb debugging", 
    "version": "0.0.1", 
    "private": true, 
    "license": "MIT", 
    "author": "me", 
    "engines": { 
     "node": "6.9.3" 
    }, 
    "dependencies": { 
     "express": "4.15.2", 
     "mongodb": "2.2.19" 
    }, 
    "scripts": { 
     "start": "node server.js", 
     "test": "mocha" 
    } 
} 
+1

더 많은 코드가 필요합니다. 분명히'self.set [self.primary.name.toLowerCase()]'는 'undefined'로 평가되고 따라서 오류가 발생합니다. 왜?에 관해서는, 우리는 당신이하고있는 일을 더 많이 볼 필요가 있습니다. 도움말 섹션에서 [mcve] (https://stackoverflow.com/help/mcve)를 참조하십시오. 전체 프로그램을 볼 필요가 없기 때문입니다. 문제를 재현하는 데 필요한 최소한의 것입니다. –

+1

더 중요한 것은 라이브러리를 디버깅하는 데 ** ** 관련되지 않습니다. 그것들은 제비 뽑기와 많은 사람을 위해 완전하게 일한다. 뭔가 잘못 됐어. 잘못된 자격 증명, 잘못된 연결 문자열 등 –

+0

내 연결 문자열은? ssl = true & replicaSet = globaldb로 끝납니다. – 3irhui34t34

답변

4

package.json 및 전체 프로젝트이기 때문에 연결이 잘 작동 당신은 복제본 세트를 사용하지 않고 오직 하나의 Cosmos DB 인스턴스만을 가지고 있습니다.

비슷한 문제는 MongoError: Pool Destroyed에서 찾을 수 있습니다.

0

나는 정확히 같은 오류가 있습니다

Thu May 25 2017 05:17:57 GMT+0000 (Coordinated Universal Time): Application has thrown an uncaught exception and is terminated: 
TypeError: Cannot read property 'electionId' of undefined 
    at ReplSetState.update (D:\home\site\wwwroot\node_modules\mongoose\node_modules\mongodb-core\lib\topologies\replset_state.js:353:70) 
    at Server.<anonymous> (D:\home\site\wwwroot\node_modules\mongoose\node_modules\mongodb-core\lib\topologies\replset.js:393:45) 
    at Server.g (events.js:291:16) 
    at emitOne (events.js:96:13) 
    at Server.emit (events.js:188:7) 
    at D:\home\site\wwwroot\node_modules\mongoose\node_modules\mongodb-core\lib\topologies\server.js:280:14 
    at D:\home\site\wwwroot\node_modules\mongoose\node_modules\mongodb-core\lib\connection\pool.js:455:18 
    at _combinedTickCallback (internal/process/next_tick.js:67:7) 
    at process._tickCallback (internal/process/next_tick.js:98:9) 
TypeError: Cannot read property 'electionId' of undefined 
    at ReplSetState.update (D:\home\site\wwwroot\node_modules\mongoose\node_modules\mongodb-core\lib\topologies\replset_state.js:353:70) 
    at Server.<anonymous> (D:\home\site\wwwroot\node_modules\mongoose\node_modules\mongodb-core\lib\topologies\replset.js:393:45) 
    at Server.g (events.js:291:16) 
    at emitOne (events.js:96:13) 
    at Server.emit (events.js:188:7) 
    at D:\home\site\wwwroot\node_modules\mongoose\node_modules\mongodb-core\lib\topologies\server.js:280:14 
    at D:\home\site\wwwroot\node_modules\mongoose\node_modules\mongodb-core\lib\connection\pool.js:455:18 
    at _combinedTickCallback (internal/process/next_tick.js:67:7) 
    at process._tickCallback (internal/process/next_tick.js:98:9) 

또한 내 노드 JS 응용 프로그램과 함께 우주-DB를 사용

.

HIER를 생성 한 모든 내 컬렉션 당신은 연결 문자열의 경우에서 &replicaSet=globaldb을 제거하여 문제를 방지 할 수 있습니다

https://github.com/aumanjoa/chronas-community/blob/master/package.json#L48 https://github.com/aumanjoa/chronas-community/

관련 문제