fix: bundle DB drivers as dependencies (fix Etherpad #7570)#939
fix: bundle DB drivers as dependencies (fix Etherpad #7570)#939JohnMcLear merged 1 commit intoether:mainfrom
Conversation
Moves the ten DB drivers back from optional peerDependencies to dependencies so consumers (notably Etherpad Docker production images) get them installed automatically. Fixes Etherpad issue ether/etherpad#7570: "Cannot find module 'mysql2'" at startup when pnpm production install skips optional peer deps.
Review Summary by QodoBundle database drivers as production dependencies
WalkthroughsDescription• Moves ten DB drivers from optional peerDependencies to dependencies • Ensures drivers install in production environments automatically • Fixes "Cannot find module" errors in Etherpad Docker images • Bumps version to 5.0.46 Diagramflowchart LR
A["Optional peerDependencies"] -->|"Move to dependencies"| B["Required dependencies"]
B -->|"Production install"| C["Drivers available at runtime"]
C -->|"Fixes"| D["Etherpad #7570"]
File Changes1. package.json
|
Code Review by Qodo
1. Node engine version mismatch
|
| "dependencies": { | ||
| "async": "^3.2.6", | ||
| "dirty-ts": "^1.1.8", | ||
| "rusty-store-kv": "^1.3.1", | ||
| "simple-git": "^3.36.0" | ||
| }, | ||
| "peerDependencies": { | ||
| "@elastic/elasticsearch": "^9.3.4", | ||
| "async": "^3.2.6", | ||
| "cassandra-driver": "^4.8.0", | ||
| "dirty-ts": "^1.1.8", | ||
| "mongodb": "^7.1.1", | ||
| "mssql": "^12.2.1", | ||
| "mysql2": "^3.22.0", | ||
| "nano": "^11.0.5", | ||
| "pg": "^8.20.0", | ||
| "redis": "^5.12.1", | ||
| "rethinkdb": "^2.4.2", | ||
| "rusty-store-kv": "^1.3.1", | ||
| "simple-git": "^3.36.0", | ||
| "surrealdb": "^2.0.3" | ||
| }, |
There was a problem hiding this comment.
1. Node engine version mismatch 🐞 Bug ☼ Reliability
package.json still declares Node ">=18.0.0" but the newly-required runtime drivers include packages that require Node >=20.x (e.g., mongodb and nano), so installs can fail for Node 18 users (especially with engine-strict) and the published engine range becomes inaccurate.
Agent Prompt
## Issue description
`package.json` advertises Node >=18, but the PR makes DB drivers hard dependencies and several of those (or their transitives) require Node >=20.x. This can break installs for Node 18 users and misrepresents supported runtime versions.
## Issue Context
New dependencies include `mongodb`, `nano`, and `@elastic/elasticsearch` (via `@elastic/transport`) which have Node >=20 engine requirements according to the lockfile.
## Fix Focus Areas
- package.json[25-40]
- package.json[107-109]
## What to change
- Either bump `engines.node` to the highest required minimum (and consider whether this warrants a semver-minor/major rather than patch), OR
- Pin/adjust the specific driver package versions to ones that support Node 18, OR
- Reconsider making these particular drivers unconditional dependencies (e.g., keep Node20-only drivers optional/peer so Node18 installs remain possible).
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| "dependencies": { | ||
| "async": "^3.2.6", | ||
| "dirty-ts": "^1.1.8", | ||
| "rusty-store-kv": "^1.3.1", | ||
| "simple-git": "^3.36.0" | ||
| }, | ||
| "peerDependencies": { | ||
| "@elastic/elasticsearch": "^9.3.4", | ||
| "async": "^3.2.6", | ||
| "cassandra-driver": "^4.8.0", | ||
| "dirty-ts": "^1.1.8", | ||
| "mongodb": "^7.1.1", | ||
| "mssql": "^12.2.1", | ||
| "mysql2": "^3.22.0", | ||
| "nano": "^11.0.5", | ||
| "pg": "^8.20.0", | ||
| "redis": "^5.12.1", | ||
| "rethinkdb": "^2.4.2", | ||
| "rusty-store-kv": "^1.3.1", | ||
| "simple-git": "^3.36.0", | ||
| "surrealdb": "^2.0.3" | ||
| }, |
There was a problem hiding this comment.
2. Unmet driver peer dependencies 🐞 Bug ☼ Reliability
By making drivers unconditional dependencies, ueberdb2 now forces installation of packages that declare non-optional peerDependencies (notably surrealdb requires tslib and typescript; mysql2 requires @types/node), which can cause install failures under strict peer-dependency enforcement and creates noisy warnings for all consumers.
Agent Prompt
## Issue description
Making DB drivers unconditional dependencies forces all consumers to install packages that have non-optional peerDependencies (`surrealdb` needs `tslib` + `typescript`, `mysql2` needs `@types/node`). In production installs (no devDependencies) and/or strict peer enforcement, this can fail.
## Issue Context
- `surrealdb@2.0.3` peers: `tslib`, `typescript`
- `mysql2@3.22.0` peer: `@types/node`
- `tslib` is not present in ueberdb2 deps; `typescript` and `@types/node` are dev-only.
## Fix Focus Areas
- package.json[25-40]
- package.json[41-67]
## What to change
Choose one:
- Add the required peers to `dependencies` (or `peerDependencies` where appropriate) so production consumers satisfy them, OR
- Switch to driver versions that do not require these peers, OR
- Avoid forcing these drivers as unconditional dependencies (e.g., keep only the actually-needed driver install-time requirements on the consumer side).
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Summary
@elastic/elasticsearch,cassandra-driver,mongodb,mssql,mysql2,nano,pg,redis,rethinkdb,surrealdb) frompeerDependencies+peerDependenciesMeta.optionalback todependencies.peerDependenciesMeta.Why
ueberdb2@5.0.45declared the drivers as optional peer deps. Production installs (e.g.,pnpm install --prod) skip optional peer deps, so consumers hitError: Cannot find module 'mysql2'at firstrequireof a driver.Reported against Etherpad Docker: ether/etherpad#7570
Test plan
npm install ueberdb2@nextinto a fresh project, thenrequire()each of the ten driver modules — all resolve