Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript & Googleapis Surge in Memory Used

We've been tracking for a while an Out of Memory error that seemed to happen from time to time in the build step.
We finally pinpointed the commit. Said commit caused the tsc --alwaysStrict build to go from 175MB (RAM) to complete the build to 656MB.

That commit only added the googleapis library to the package.json and use it like so import { google } from "googleapis";. Those two changes alone created this spike.

Another thing that we saw is that the inclusion of the library on the package.json incremented the build by 100MB, however, once we add the import it goes all the way up to 600MB.
It is important to say that we are only interested in gSheets.

I see a couple options going forward but I do not like any of those:

  1. Increasing the RAM of the server (currently 1GB)
  2. Using a custom or non-oficial library for this purpose

Is there another way to solve this?

like image 761
eversor Avatar asked Nov 16 '22 07:11

eversor


1 Answers

I encountered the same issue, though for me the problem surfaced when running jest unit-tests, even the simplest test would consume up to 1GB of memory and cause our CI machine to crash.

seems like some progress was made and you can now import specific modules from @googleapis

look at: https://github.com/googleapis/google-api-nodejs-client/issues/2187

for example: https://www.npmjs.com/package/@googleapis/drive https://www.npmjs.com/package/@googleapis/calendar

haven't tried it yet, but I hope it will solve the issue.

EDIT: tried using the service-specific packages i mentioned above, and it worked like a charm. give it a try

like image 99
zivaricha Avatar answered Dec 10 '22 01:12

zivaricha