[COMPASS-4741] Can't create/delete database after re-connecting Compass Created: 30/Mar/21  Updated: 29/Oct/23  Resolved: 06/Apr/21

Status: Closed
Project: Compass
Component/s: CRUD
Affects Version/s: 1.26.1
Fix Version/s: 1.26.1

Type: Bug Priority: Major - P3
Reporter: Sergey Petushkov Assignee: Sergey Petushkov
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File image-2021-03-30-10-23-16-046.png    
Issue Links:
Related
is related to COMPASS-4742 Compass plugins are leaking event lis... Open
Documentation Changes: Not Needed
Sprint: Iteration Yucca, Iteration Z

 Description   

Problem Description

Stale reference in compass-crud plugin causes issues when re-connecting Compass

Steps to Reproduce

  1. Open Compass, connect to any MongoDB instance (Atlas or localhost)
  2. Click on a database
  3. click on a collection (you must view the documents of the collection)
  4. Disconnect
  5. Re-connect to the same instance
  6. Create a database (fails with the db null error)

Expected Results

Data base is created

Actual Results

Database creation fails with an error "Can't read db of null"

mongodb-compass:crud:crud-store warning: unable to count documents +0ms TypeError: Cannot read property 'db' of null
    at descriptor.value._database (/Users/sergey.petushkov/tmp/MongoDB Compass Beta 1.26.1-beta.3.app/Contents/Resources/app.asar/node_modules/mongodb-data-service/lib/native-client.js:1242)
    at descriptor.value._collection (/Users/sergey.petushkov/tmp/MongoDB Compass Beta 1.26.1-beta.3.app/Contents/Resources/app.asar/node_modules/mongodb-data-service/lib/native-client.js:1209)
    at descriptor.value.count (/Users/sergey.petushkov/tmp/MongoDB Compass Beta 1.26.1-beta.3.app/Contents/Resources/app.asar/node_modules/mongodb-data-service/lib/native-client.js:254)
    at descriptor.value (/Users/sergey.petushkov/tmp/MongoDB Compass Beta 1.26.1-beta.3.app/Contents/Resources/app.asar/node_modules/mongodb-data-service/lib/native-client.js:1324)
    at DataService.count (/Users/sergey.petushkov/tmp/MongoDB Compass Beta 1.26.1-beta.3.app/Contents/Resources/app.asar/node_modules/mongodb-data-service/lib/data-service.js:187)
    at internal/util.js:286
    at new Promise (<anonymous>)
    at bound count (internal/util.js:285)
    at /Users/sergey.petushkov/tmp/MongoDB Compass Beta 1.26.1-beta.3.app/Contents/Resources/app.asar/node_modules/@mongodb-js/compass-crud/lib/index.js:913

Additional Notes

The issue seems to be caused by compass-crud plugin keeping a reference to the old dataService. See this Slack thread for more info. Check additionally what are the other places that can cause a similar issue



 Comments   
Comment by Githook User [ 30/Mar/21 ]

Author:

{'name': 'Sergey', 'email': 'petushkov.sergey@gmail.com', 'username': 'gribnoysup'}

Message: feat: Add isConnected method to dataService to allow easy access to connection status of the internal MongoClient COMPASS-4741 (#320)

  • feat: Add isConnected method to dataService to allow easy access to connection status of the internal MongoClient
Generated at Wed Feb 07 22:37:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.