Cannot read properties of undefined (reading 'collections')
See original GitHub issueHi,
I encounter the following error while connecting…
C:\projects\otto-js\node_modules\ottoman\lib\ottoman\ottoman.js:173
return this.bucket.collections();
^
TypeError: Cannot read properties of undefined (reading 'collections')
at Ottoman.get collectionManager [as collectionManager] (C:\projects\otto-js\node_modules\ottoman\lib\ottoman\ottoman.js:173:28)
at Ottoman.<anonymous> (C:\projects\otto-js\node_modules\ottoman\lib\ottoman\ottoman.js:375:59)
at Generator.next (<anonymous>)
at C:\projects\otto-js\node_modules\ottoman\lib\ottoman\ottoman.js:27:71
at new Promise (<anonymous>)
at __awaiter (C:\projects\otto-js\node_modules\ottoman\lib\ottoman\ottoman.js:23:12)
at Ottoman.ensureCollections (C:\projects\otto-js\node_modules\ottoman\lib\ottoman\ottoman.js:367:16)
at Ottoman.<anonymous> (C:\projects\otto-js\node_modules\ottoman\lib\ottoman\ottoman.js:444:24)
at Generator.next (<anonymous>)
at C:\projects\otto-js\node_modules\ottoman\lib\ottoman\ottoman.js:27:71
Using the following script
const {
Ottoman, getModel, Schema, SearchConsistency,
} = require('ottoman');
const ottoman = new Ottoman({ collectionName: '_default' });
ottoman.connect({
connectionString: 'couchbase://localhost',
bucketName: 'testBucket',
username: 'user',
password: 'password',
});
const modelOptions = {
scopeName: 'testpostscope',
collectionName: 'testpostcollection',
maxExpiry: 1200,
};
const schema = new Schema({
text: { type: String },
});
ottoman.model('message', schema, modelOptions);
ottoman.start();
const messageModel = getModel('message');
messageModel.create({ text: 'test' })
.then((result) => console.log(result));
Using ottoman 2.1.0
. Any idea?
Thanks!
Not sure if it helps, here’s the log with debug on
❯ node index.js
couchnode:lcb:info (instance @ C:\Jenkins\workspace\nodejs\couchnode\couchnode-scripted-build-pipeline\couchnode\deps\lcb\src\instance.cc:521) Version=3.2.4-njs, Changeset=38cc0708dfcc5a706c6b21dc80bcd84f05890225 +0ms
couchnode:lcb:info (instance @ C:\Jenkins\workspace\nodejs\couchnode\couchnode-scripted-build-pipeline\couchnode\deps\lcb\src\instance.cc:522) Effective connection string: couchbase://localhost?config_total_timeout=30s&enable_tracing=off&enable_operation_metrics=off&client_string=couchnode%2F3.2.4%20(node%2F16.13.2%3B%20v8%2F9.4.146.24-node.14%3B%20ssl%2F1.1.1l%2Bquic). Bucket=(null) +1ms
couchnode:lcb:debug (instance @ C:\Jenkins\workspace\nodejs\couchnode\couchnode-scripted-build-pipeline\couchnode\deps\lcb\src\instance.cc:389) Applying initial cntl config_total_timeout=30s +0ms
couchnode:lcb:debug (instance @ C:\Jenkins\workspace\nodejs\couchnode\couchnode-scripted-build-pipeline\couchnode\deps\lcb\src\instance.cc:389) Applying initial cntl enable_tracing=off +0ms couchnode:lcb:debug (instance @ C:\Jenkins\workspace\nodejs\couchnode\couchnode-scripted-build-pipeline\couchnode\deps\lcb\src\instance.cc:389) Applying initial cntl enable_operation_metrics=off +0ms
couchnode:lcb:debug (instance @ C:\Jenkins\workspace\nodejs\couchnode\couchnode-scripted-build-pipeline\couchnode\deps\lcb\src\instance.cc:389) Applying initial cntl client_string=couchnode/3.2.4 (node/16.13.2; v8/9.4.146.24-node.14; ssl/1.1.1l+quic) +1ms
couchnode:lcb:info (instance @ C:\Jenkins\workspace\nodejs\couchnode\couchnode-scripted-build-pipeline\couchnode\deps\lcb\src\instance.cc:212) DNS SRV lookup failed: LCB_ERR_UNKNOWN_HOST (1049). Ignore this if not relying on DNS SRV records +11ms
couchnode:lcb:debug (instance @ C:\Jenkins\workspace\nodejs\couchnode\couchnode-scripted-build-pipeline\couchnode\deps\lcb\src\instance.cc:155) Adding host localhost:8091 to initial HTTP bootstrap list +10ms
couchnode:lcb:debug (instance @ C:\Jenkins\workspace\nodejs\couchnode\couchnode-scripted-build-pipeline\couchnode\deps\lcb\src\instance.cc:155) Adding host localhost:11210 to initial CCCP bootstrap list +0ms
couchnode:lcb:trace (instance @ C:\Jenkins\workspace\nodejs\couchnode\couchnode-scripted-build-pipeline\couchnode\deps\lcb\src\instance.cc:193) Bootstrap hosts loaded (cccp:1, http:1) +0ms
couchnode:lcb:info (bootstrap @ C:\Jenkins\workspace\nodejs\couchnode\couchnode-scripted-build-pipeline\couchnode\deps\lcb\src\bootstrap.cc:277) Requested network configuration: heuristic +3ms
couchnode:lcb:debug (confmon @ C:\Jenkins\workspace\nodejs\couchnode\couchnode-scripted-build-pipeline\couchnode\deps\lcb\src\bucketconfig\confmon.cc:94) Preparing providers (this may be called multiple times) +2ms
couchnode:lcb:debug (confmon @ C:\Jenkins\workspace\nodejs\couchnode\couchnode-scripted-build-pipeline\couchnode\deps\lcb\src\bucketconfig\confmon.cc:100) Provider CCCP is ENABLED +1ms
couchnode:lcb:debug (confmon @ C:\Jenkins\workspace\nodejs\couchnode\couchnode-scripted-build-pipeline\couchnode\deps\lcb\src\bucketconfig\confmon.cc:100) Provider HTTP is ENABLED +0ms
couchnode:lcb:trace (confmon @ C:\Jenkins\workspace\nodejs\couchnode\couchnode-scripted-build-pipeline\couchnode\deps\lcb\src\bucketconfig\confmon.cc:319) Refreshing current cluster map (bucket: (null)) +2ms
couchnode:lcb:info (cccp @ C:\Jenkins\workspace\nodejs\couchnode\couchnode-scripted-build-pipeline\couchnode\deps\lcb\src\bucketconfig\bc_cccp.cc:176) Requesting connection to node localhost:11210 for CCCP configuration +2ms
couchnode:lcb:debug (lcbio_mgr @ C:\Jenkins\workspace\nodejs\couchnode\couchnode-scripted-build-pipeline\couchnode\deps\lcb\src\lcbio\manager.cc:501) <localhost:11210> (HE=00000255A967DA30) Creating new connection because none are available in the pool +1ms
couchnode:lcb:trace (lcbio_mgr @ C:\Jenkins\workspace\nodejs\couchnode\couchnode-scripted-build-pipeline\couchnode\deps\lcb\src\lcbio\manager.cc:413) <localhost:11210> (HE=00000255A967DA30) New pool entry: I=000002559FA5DB30 +2ms
couchnode:lcb:info (connection @ C:\Jenkins\workspace\nodejs\couchnode\couchnode-scripted-build-pipeline\couchnode\deps\lcb\src\lcbio\connect.cc:497) <localhost:11210> (SOCK=f4f4a311b8151120) Starting. Timeout=2000000us +1ms
Issue Analytics
- State:
- Created 2 years ago
- Comments:19 (10 by maintainers)
Top Results From Across the Web
javascript - TypeError: Cannot read properties of undefined ...
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'collection'). I don't know what else to do, can someone help ...
Read more >TypeError: Cannot read properties of undefined ... - MongoDB
I have this code here: import { MongoClient } from "mongodb"; const createConnection = () => { // let current = null; const...
Read more >cannot read properties of undefined (reading 'collection')
To solve the "Cannot read properties of undefined" error, make sure to insert the JS script tag at the bottom of the body....
Read more >Cannot read property 'collection' of undefined #1263 - GitHub
Im using the sample app "react-native-firebase-starter" to try out the feature of firestore. I follow the instruction on the page and everything ...
Read more >Cannot read properties of undefined (reading 'type')
I have a Dashboard in one of the collections with all user-view access. Other than Admin users , Cannot read properties of undefined...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It is indeed a mystery.
I agree with you on disconnecting and have added it.
And I believe that #602 is the same issue like this, I only realize this recently, and will be closing that as well.
Appreciate your time and help in troubleshooting this issue with me
this way:
the model will be registered when the file will be imported (attachments.model.ts), the
model
function will be executed when javascript is importing files (when the code starts to be executed - execution time).in the previous version:
the model will be not registered until the exported default function will be executed. (feathersjs will execute it to create the service when requested) therefore when the
start
function is executed there are no models registered yet, with no models, Ottoman has no information to create scopes, collections, indexes, …Summarize:
imagine a index.js file with this content
node index.js
will produce “executed” (our modification achieve this)instead this other index.js file with content:
node index.js
will produce no output. (console.log
statement never was executed, just from load the files)