-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update with-mongodb to be TypeScript-friendly #19383
Conversation
I slightly modified the approach so TypeScript can correctly infer types without actually having to type anything but the global: **index.d.ts** ```ts import { Db, MongoClient } from "mongodb"; declare global { namespace NodeJS { interface Global { mongoCache: { conn: { client: MongoClient | null; db: Db | null; } promise: Promise<MongoClient> | null; }; } } } ```
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
buildDuration | 9.8s | 9.7s | -101ms |
nodeModulesSize | 84.9 MB | 84.9 MB | ✓ |
Page Load Tests Overall increase ✓
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.237 | 2.22 | -0.02 |
/ avg req/sec | 1117.7 | 1125.9 | +8.2 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.526 | 1.453 | -0.07 |
/error-in-render avg req/sec | 1638.27 | 1721 | +82.73 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
677f882d2ed8..8b81.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-9cc22a8..b04f.js gzip | 6.53 kB | 6.53 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_app-3b0cf13..85f8.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-6f635..c393.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-d4ffc3..9e0f.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-b618194..5477.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..924c.js gzip | 284 B | 284 B | ✓ |
withRouter-7..c13d.js gzip | 284 B | 284 B | ✓ |
Overall change | 8.01 kB | 8.01 kB | ✓ |
Client Build Manifests
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
index.html gzip | 615 B | 615 B | ✓ |
link.html gzip | 622 B | 622 B | ✓ |
withRouter.html gzip | 609 B | 609 B | ✓ |
Overall change | 1.85 kB | 1.85 kB | ✓ |
Serverless Mode
General
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
buildDuration | 11.6s | 11.3s | -292ms |
nodeModulesSize | 84.9 MB | 84.9 MB | ✓ |
Client Bundles (main, webpack, commons)
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
677f882d2ed8..8b81.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-9cc22a8..b04f.js gzip | 6.53 kB | 6.53 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_app-3b0cf13..85f8.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-6f635..c393.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-d4ffc3..9e0f.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-b618194..5477.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..924c.js gzip | 284 B | 284 B | ✓ |
withRouter-7..c13d.js gzip | 284 B | 284 B | ✓ |
Overall change | 8.01 kB | 8.01 kB | ✓ |
Client Build Manifests
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Serverless bundles
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_error.js | 915 kB | 915 kB | ✓ |
404.html | 2.67 kB | 2.67 kB | ✓ |
hooks.html | 1.92 kB | 1.92 kB | ✓ |
index.js | 915 kB | 915 kB | ✓ |
link.js | 973 kB | 973 kB | ✓ |
routerDirect.js | 966 kB | 966 kB | ✓ |
withRouter.js | 966 kB | 966 kB | ✓ |
Overall change | 4.74 MB | 4.74 MB | ✓ |
Stats from current PRDefault Server Mode (Decrease detected ✓)General
Page Load Tests Overall decrease
|
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.161 | 2.217 | |
/ avg req/sec | 1156.72 | 1127.5 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.248 | 1.252 | 0 |
/error-in-render avg req/sec | 2002.74 | 1997.02 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
677f882d2ed8..8b81.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-9cc22a8..b04f.js gzip | 6.53 kB | 6.53 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_app-3b0cf13..85f8.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-6f635..c393.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-d4ffc3..9e0f.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-b618194..5477.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..924c.js gzip | 284 B | 284 B | ✓ |
withRouter-7..c13d.js gzip | 284 B | 284 B | ✓ |
Overall change | 8.01 kB | 8.01 kB | ✓ |
Client Build Manifests
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
index.html gzip | 615 B | 615 B | ✓ |
link.html gzip | 622 B | 622 B | ✓ |
withRouter.html gzip | 609 B | 609 B | ✓ |
Overall change | 1.85 kB | 1.85 kB | ✓ |
Serverless Mode
General
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
buildDuration | 11.2s | 11.6s | |
nodeModulesSize | 84.9 MB | 84.9 MB | ✓ |
Client Bundles (main, webpack, commons)
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
677f882d2ed8..8b81.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-9cc22a8..b04f.js gzip | 6.53 kB | 6.53 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_app-3b0cf13..85f8.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-6f635..c393.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-d4ffc3..9e0f.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-b618194..5477.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..924c.js gzip | 284 B | 284 B | ✓ |
withRouter-7..c13d.js gzip | 284 B | 284 B | ✓ |
Overall change | 8.01 kB | 8.01 kB | ✓ |
Client Build Manifests
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Serverless bundles
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_error.js | 915 kB | 915 kB | ✓ |
404.html | 2.67 kB | 2.67 kB | ✓ |
hooks.html | 1.92 kB | 1.92 kB | ✓ |
index.js | 915 kB | 915 kB | ✓ |
link.js | 973 kB | 973 kB | ✓ |
routerDirect.js | 966 kB | 966 kB | ✓ |
withRouter.js | 966 kB | 966 kB | ✓ |
Overall change | 4.74 MB | 4.74 MB | ✓ |
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
buildDuration | 8.6s | 8.6s | -47ms |
nodeModulesSize | 84.9 MB | 84.9 MB | ✓ |
Page Load Tests Overall increase ✓
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 1.919 | 1.887 | -0.03 |
/ avg req/sec | 1302.87 | 1324.83 | +21.96 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.082 | 1.079 | 0 |
/error-in-render avg req/sec | 2309.58 | 2317.27 | +7.69 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
677f882d2ed8..8b81.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-9cc22a8..b04f.js gzip | 6.53 kB | 6.53 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_app-3b0cf13..85f8.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-6f635..c393.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-d4ffc3..9e0f.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-b618194..5477.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..924c.js gzip | 284 B | 284 B | ✓ |
withRouter-7..c13d.js gzip | 284 B | 284 B | ✓ |
Overall change | 8.01 kB | 8.01 kB | ✓ |
Client Build Manifests
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
index.html gzip | 615 B | 615 B | ✓ |
link.html gzip | 622 B | 622 B | ✓ |
withRouter.html gzip | 609 B | 609 B | ✓ |
Overall change | 1.85 kB | 1.85 kB | ✓ |
Serverless Mode
General
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
buildDuration | 9.7s | 9.9s | |
nodeModulesSize | 84.9 MB | 84.9 MB | ✓ |
Client Bundles (main, webpack, commons)
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
677f882d2ed8..8b81.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-9cc22a8..b04f.js gzip | 6.53 kB | 6.53 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_app-3b0cf13..85f8.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-6f635..c393.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-d4ffc3..9e0f.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-b618194..5477.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..924c.js gzip | 284 B | 284 B | ✓ |
withRouter-7..c13d.js gzip | 284 B | 284 B | ✓ |
Overall change | 8.01 kB | 8.01 kB | ✓ |
Client Build Manifests
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Serverless bundles
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_error.js | 915 kB | 915 kB | ✓ |
404.html | 2.67 kB | 2.67 kB | ✓ |
hooks.html | 1.92 kB | 1.92 kB | ✓ |
index.js | 915 kB | 915 kB | ✓ |
link.js | 973 kB | 973 kB | ✓ |
routerDirect.js | 966 kB | 966 kB | ✓ |
withRouter.js | 966 kB | 966 kB | ✓ |
Overall change | 4.74 MB | 4.74 MB | ✓ |
Remaining failures don't seem to be related to my changes 👀 |
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
buildDuration | 9.5s | 9.6s | |
nodeModulesSize | 84.9 MB | 84.9 MB | ✓ |
Page Load Tests Overall increase ✓
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.189 | 2.285 | |
/ avg req/sec | 1141.91 | 1094.21 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.468 | 1.409 | -0.06 |
/error-in-render avg req/sec | 1703.25 | 1773.76 | +70.51 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
677f882d2ed8..8b81.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-9cc22a8..b04f.js gzip | 6.53 kB | 6.53 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_app-3b0cf13..85f8.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-6f635..c393.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-d4ffc3..9e0f.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-b618194..5477.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..924c.js gzip | 284 B | 284 B | ✓ |
withRouter-7..c13d.js gzip | 284 B | 284 B | ✓ |
Overall change | 8.01 kB | 8.01 kB | ✓ |
Client Build Manifests
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
index.html gzip | 615 B | 615 B | ✓ |
link.html gzip | 622 B | 622 B | ✓ |
withRouter.html gzip | 609 B | 609 B | ✓ |
Overall change | 1.85 kB | 1.85 kB | ✓ |
Serverless Mode
General
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
buildDuration | 10.8s | 10.8s | |
nodeModulesSize | 84.9 MB | 84.9 MB | ✓ |
Client Bundles (main, webpack, commons)
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
677f882d2ed8..8b81.js gzip | 12.8 kB | 12.8 kB | ✓ |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-9cc22a8..b04f.js gzip | 6.53 kB | 6.53 kB | ✓ |
webpack-e067..f178.js gzip | 751 B | 751 B | ✓ |
Overall change | 59 kB | 59 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
polyfills-4b..e242.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_app-3b0cf13..85f8.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-6f635..c393.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-d4ffc3..9e0f.js gzip | 887 B | 887 B | ✓ |
index-17468f..5d83.js gzip | 227 B | 227 B | ✓ |
link-b618194..5477.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..924c.js gzip | 284 B | 284 B | ✓ |
withRouter-7..c13d.js gzip | 284 B | 284 B | ✓ |
Overall change | 8.01 kB | 8.01 kB | ✓ |
Client Build Manifests
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Serverless bundles
vercel/next.js canary | Zertz/next.js patch-1 | Change | |
---|---|---|---|
_error.js | 915 kB | 915 kB | ✓ |
404.html | 2.67 kB | 2.67 kB | ✓ |
hooks.html | 1.92 kB | 1.92 kB | ✓ |
index.js | 915 kB | 915 kB | ✓ |
link.js | 973 kB | 973 kB | ✓ |
routerDirect.js | 966 kB | 966 kB | ✓ |
withRouter.js | 966 kB | 966 kB | ✓ |
Overall change | 4.74 MB | 4.74 MB | ✓ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Zertz LGTM. Thank you!
edit: "noImplicitAny": false is a dirty hack |
I slightly modified the approach so TypeScript can correctly infer types without actually having to type anything but the global:
index.d.ts