Slow startup
See original GitHub issue1) Is this a client library issue or a product issue?
It takes a very long time for require('googleapis')
to run, because it eagerly requires every API submodule. Notwithstanding the fact that the source code uses static import
rather than require
, this package could most likely be built in such a way that submodules were required lazily, so that in code like this, for example…
const { google } = require('googleapis');
const auth = google.auth.fromJSON(credentials);
auth.scopes = ['https://www.googleapis.com/auth/drive.readonly'];
const client = google.drive('v3');
const { data } = await client.files.export(file);
…only the submodules for google.auth
and google.drive
would be require
d.
Alternatively, or additionally, exposing submodules directly could solve the problem:
const { fromJSON } = require('googleapis/auth');
const auth = fromJSON(credentials);
const client = require('googleapis/drive/v3');
const { data } = await client.files.export(file);
2) Did someone already solve this?
Couldn’t find any prior discussion
3) Do you have a support contract?
No
Environment details
- OS: MacOS
- Node.js version: 12.18.3
- npm version: 6.14.6
googleapis
version: 59
Steps to reproduce
function timed_require(x) {
const start = Date.now();
const mod = require(x);
console.log(`required ${x} in ${Date.now() - start}ms`);
return mod;
}
timed_require('googleapis');
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:6 (2 by maintainers)
Top Results From Across the Web
8 Ways to Fix Slow Boot Times in Windows 10 - MakeUseOf
8 Ways to Fix Slow Boot Times in Windows 10 · 1. Disable Fast Startup · 2. Adjust Paging File Settings · 3....
Read more >How to Fix Slow Startup on Windows 10 | SoftwareKeep
Windows 10 startup is slow? We've compiled 7 working solutions to help you fix slow startup on Windows 10.
Read more >Full Guide to Fix Windows 10 Slow Boot After Update - EaseUS
Fix 2. Disable unnecessary startup programs in Task Manager, Too many startup programs will slow down the computer. Right-click the taskbar, ...
Read more >Fix the Windows 10 Slow Boot Issue: 9 Easy Solutions
How can I fix a slow boot time in Windows 10? · 1. Use the Windows 10 Startup Manager · 2. Update your...
Read more >Solved: Windows 10/11 Slow Boot [2022 Guide] - Driver Easy
How do I fix Windows 10 slow boot? · Disable Fast Startup · Disable Processes with High Startup Impact · Update your graphics...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@alexblack wow, this is a blast from the past 😆, so I work on client libraries at Google now.
@alexblack @Rich-Harris @haohaolee, we just started publishing individual libraries from googleapis, which should significantly speed up startup/compile time:
You can find them under the
@googleapis
namespace on npm. Once you install a dependency, it should work almost identically to using the top level module, e.g.,Closing this issue, now that we have the ability to install individual APIs. Let us know if you continue to have any issues.