Azure / autorest.typescript

Extension for AutoRest (https://github.com/Azure/autorest) that generates TypeScript code. The transpiled javascript code is isomorphic. It can be run in browser and in node.js environment.
MIT License
177 stars 75 forks source link

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory #1019

Closed marche0133 closed 3 years ago

marche0133 commented 3 years ago

Describe the bug

MicrosoftTeams-image (1)

After a recent install of npm and node, the autorest javascript and autorest java does not work. I tried to increase the memory by --max-memory-size=3888 but does not work.

npm 6.14.13 node v14.17.0 autorest 3.2.3

autorest packages image

E:\WebstormProjects\azure-sdk-for-js-pr\sdk\communication\communication-router>npm run build:autorest

> @azure/communication-router@1.0.0-beta.7 build:autorest E:\WebstormProjects\azure-sdk-for-js-pr\sdk\communication\communication-router
> autorest ./swagger/README.md --typescript --version=3.0.6267 --v3 --package-version=1.0.0-beta.5 && rushx format

AutoRest code generation utility [cli version: 3.2.3; node: v14.17.0, max-memory: 1024 MB]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
   Loading AutoRest core      'C:\Users\marcma\.autorest\@autorest_core@3.0.6267\node_modules\@autorest\core\dist' (3.0.6267)
   Loading AutoRest extension '@autorest/typescript' (6.0.0-dev.20210114.1->6.0.0-dev.20210114.1)
   Loading AutoRest extension '@autorest/modelerfour' (4.15.442->4.15.442)
   Loading AutoRest extension '@autorest/modelerfour' (4.15.448->4.15.448)

<--- Last few GCs --->

[14876:03DA7FF8]       81 ms: Mark-sweep 1.0 (3.5) -> 1.0 (3.5) MB, 1.4 / 0.0 ms  (average mu = 0.590, current mu = 0.191) allocation failure GC in old space requested
[14876:03DA7FF8]       83 ms: Mark-sweep (reduce) 1.0 (3.5) -> 1.0 (3.5) MB, 1.1 / 0.0 ms  (average mu = 0.492, current mu = 0.230) last resort GC in old space requested
[14876:03DA7FF8]       84 ms: Mark-sweep (reduce) 1.0 (2.5) -> 1.0 (3.5) MB, 1.5 / 0.0 ms  (average mu = 0.316, current mu = 0.020) last resort GC in old space requested

<--- JS stacktrace --->

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
Process() cancelled due to failure
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @azure/communication-router@1.0.0-beta.7 build:autorest: `autorest ./swagger/README.md --typescript --version=3.0.6267 --v3 --package-version=1.0.0-beta.5 && rushx format`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @azure/communication-router@1.0.0-beta.7 build:autorest script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\marcma\AppData\Roaming\npm-cache\_logs\2021-06-08T16_45_10_763Z-debug.log

I tried to run autorest-java but seems not working as well.

E:\StudioProjects\autorest.java>E:\StudioProjects\azure-sdk-for-android\sdk\communication\azure-communication-chat\swagger\README.md^Z

E:\StudioProjects\autorest.java>autorest E:\StudioProjects\azure-sdk-for-android\sdk\communication\azure-communication-chat\swagger\README.md --java --v4 --use=@autorest/java@4.0.11
AutoRest code generation utility [cli version: 3.2.3; node: v14.17.0, max-memory: 1024 MB]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
NOTE: AutoRest core version selected from configuration: ~3.1.0.
   Loading AutoRest core      'C:\Users\marcma\.autorest\@autorest_core@3.1.3\node_modules\@autorest\core\dist' (3.1.3)
INFORMATION: > Loading AutoRest extension '@autorest/java' (4.0.11->4.0.11)
INFORMATION: > Loading local AutoRest extension '@autorest/java.vanilla' (C:\Users\marcma\.autorest\@autorest_java@4.0.11\node_modules\@autorest\java\javagen)
INFORMATION: > Loading local AutoRest extension '@autorest/java.preprocessor' (C:\Users\marcma\.autorest\@autorest_java@4.0.11\node_modules\@autorest\java\javagen\..\preprocessor)
INFORMATION: > Loading local AutoRest extension '@autorest/java.postprocessor' (C:\Users\marcma\.autorest\@autorest_java@4.0.11\node_modules\@autorest\java\javagen\..\postprocessor)
INFORMATION: > Loading AutoRest extension '@autorest/modelerfour' (4.15.447->4.15.447)

<--- Last few GCs --->

[17616:04168D88]      252 ms: Mark-sweep 1.0 (3.5) -> 1.0 (3.5) MB, 3.3 / 0.0 ms  (average mu = 0.650, current mu = 0.254) allocation failure GC in old space requested
[17616:04168D88]      256 ms: Mark-sweep (reduce) 1.0 (3.5) -> 1.0 (3.5) MB, 2.6 / 0.0 ms  (average mu = 0.556, current mu = 0.238) last resort GC in old space requested
[17616:04168D88]      260 ms: Mark-sweep (reduce) 1.0 (2.5) -> 1.0 (3.5) MB, 4.1 / 0.0 ms  (average mu = 0.364, current mu = 0.011) last resort GC in old space requested

<--- JS stacktrace --->

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
Process() cancelled due to failure


**Expected behavior**
It should run and parse the swagger.

**Additional context**
It throws a out of memory error.
sarangan12 commented 3 years ago

@marche0133 Thanks for reporting this issue. Let me try this out locally. I believe this might be an autorest core issue. I will confirm that and update the issue soon. If that is the case, I will raise this in the autorest repo.

marche0133 commented 3 years ago

Hi, I upgrade Node to latest version v16 and delete npm and npm-cache folder in roaming, the autorest works now.

sarangan12 commented 3 years ago

@marche0133 Thanks for the update, Closing this issue now.