System Information
- Strapi Version: 3.6.2
- Operating System: Ubuntu 20
- Database: Postgres
- Node Version: 14.19.3
- NPM Version: 6.14.17
The password for my Strapi database is stored in GCP’s Secret Manager. The call to retrieve the password from the Secret Manager returns a Promise. So, I thought I could simply put the following in my database.js
file:
module.exports = async ({env}) => {
const password = await getThePasswordPromiseFromGcp();
return {
defaultConnection: 'default',
connections: {
default: {
connector: 'bookshelf',
settings: {
client: 'postgres',
host: `/cloudsql/${env('INSTANCE_CONNECTION_NAME')}`,
database: env('DATABASE_NAME'),
username: env('DATABASE_USERNAME'),
password: password
}
}
}
}
}
}
However, this causes the following error on startup:
debug ⛔️ Server wasn't able to start properly.install: my_project@0.0.0
error TypeError: Cannot convert undefined or null to object
at Function.values (<anonymous>)
at Object.load (/project/node_modules/strapi-database/lib/connector-registry.js:17:39)
at DatabaseManager.initialize (/project/node_modules/strapi-database/lib/database-manager.js:37:21)
at Strapi.load (/project/node_modules/strapi/lib/Strapi.js:354:19)
at async Strapi.start (/project/node_modules/strapi/lib/Strapi.js:196:9)
So, what is the correct way to asynchronously initialize Strapi’s database?