Comments (3)
After sleeping on it, I thought to try again with a fresh mongodb cluster and using mongodb example data (sample_mflix dataset). With this, I was able to make a connection using these settings:
{
resolve: `gatsby-source-mongodb`,
options: {
connectionString: process.env.MONGODB_URI,
dbName: process.env.MONGODB_DB,
collection: process.env.MONGODB_COLLECTION,
extraParams: {
retryWrites: true,
w: `majority`,
},
},
},
So having established a connect to mongodb, I tried again with my data and again it failed. So then I got to thinking my data is too big (±300k items). Turns out, this is likely the problem. When I adjusted my settings to include a query to limit what data I got back, I started getting data:
{
resolve: `gatsby-source-mongodb`,
options: {
connectionString: process.env.MONGODB_URI,
dbName: process.env.MONGODB_DB,
collection: process.env.MONGODB_COLLECTION,
extraParams: {
retryWrites: true,
w: `majority`,
},
query: {
[process.env.MONGODB_COLLECTION]: { field: { $eq: value } }
},
},
},
It appears that the plugin does not support mongodb aggregations, which would be better than the query method (if that's wrong, documentation about using aggregation with this plugin would be great).
Additionally, how can a site using this plugin scale to hundreds of thousands / millions of pages if indeed the plugin struggles to pull so much data? Is there another method? Further optimizations?
So at this point I'm not 100% sure if this is a bug, or a support request, but I'll leave this here for now.
from gatsby.
Update: I reported this issue while traveling and working with my Apple MBA M2 laptop, now that I am home, I'm trying to continue development on an Apple iMac i7 computer (specs below from gatsby info --clipboard
) and with the exact same settings and .env data, I am getting this error in the console:
ERROR UNKNOWN
(node:6004) [DEP0170] DeprecationWarning: The URL mongodb://{username}:{password}@ac-lahiygk-shard-00-01
.0lxmxaq.mongodb.net:27017,ac-lahiygk-shard-00-00.0lxmxaq.mongodb.net:27017,ac-lahiygk-shard-00-02.0lxmxaq.mongodb.n
et:27017/test?authSource=admin&replicaSet=atlas-3ei0ma-shard-0&retryWrites=true&w=majority&ssl=true is invalid.
Future versions of Node.js will throw an error.
(Use `node --trace-deprecation ...` to show where the warning was created)
Which is really weird because a) I don't get it on both computers, and b) the URL in that error isn't constructed similarly to the one I am providing: mongodb+srv://{username}:{password}@{database}.0lxmxaq.mongodb.net
So I have no idea where that error is getting that URL from.
System:
OS: macOS 13.6.3
CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
Yarn: 1.22.21 - /usr/local/bin/yarn
npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
Browsers:
Chrome: 121.0.6167.139
Safari: 17.1.2
npmPackages:
gatsby: ^5.13.2 => 5.13.3
gatsby-plugin-image: ^3.13.1 => 3.13.1
gatsby-plugin-mdx: ^5.13.1 => 5.13.1
gatsby-plugin-postcss: ^6.13.1 => 6.13.1
gatsby-plugin-sharp: ^5.13.1 => 5.13.1
gatsby-plugin-sitemap: ^6.13.1 => 6.13.1
gatsby-source-filesystem: ^5.13.1 => 5.13.1
gatsby-source-mongodb: ^5.13.1 => 5.13.1
gatsby-transformer-sharp: ^5.13.1 => 5.13.1
from gatsby.
Update: I noticed that on the first computer I was running node v18.18.0 and on the second computer I was running node v20.10.0. I changed the node version on the second computer to match the first and now I get a successful build.
from gatsby.
Related Issues (20)
- ModuleParseError: Module parse failed: Unexpected character '@' (2:0) after upgrading gatsby to v5 HOT 1
- `allMarkdownRemark` graphql query in `createPages` intermittently hangs when `excerpt` or `timeToRead` fields are included
- function build error: Error: Module build failed: UnhandledSchemeError HOT 2
- Gatsby 5 is dead? HOT 1
- webpack and other js resources not found when using a subfolder of a static s3 website to serve public files
- Gatsby static site generation not fully prerendering HTML with loadable imports
- Gatsby minimal TS starter generates code with deprecated React import
- gatsby-transformer-remark doesn't accept "engines" plugin option for graymatter
- matchPath seems to be broken since adapters
- The first Headless CMS starter link is broken
- Gatsby + Directus = Build not working HOT 1
- Validation error
- Unexpected missing while creating page
- Invoking imported function inside `createPages` results in error HOT 1
- Gatsby 4 Upgrade - SyntaxError: Invalid left-hand side in assignment
- command curl -X POST http://localhost:8000/__refresh doesn't delete the documents from the CMS
- Serverless function in Gatsby site throwing error and not returning data locally HOT 1
- Using webpack-dev-middleware results with npm audit high vulnerability HOT 1
- Add a short how-to article for removing the 8px margin in html body
- Error using TypeScript package using workspace in gatsby-node.ts : ReferenceError: Cannot access 'D' before initialization
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gatsby.