Closed artechventure closed 2 years ago
Hi @artechventure
Thank you for the reproduce repository, we will look into this issue. There are some solutions from previous issues worth trying. You can have a look at #1877 and see if they solve your problem.
Even I am facing the same issue. Please help Thanks!
Any updates???
Still facing the same issue.
React Native: 0.60.5
Tried with different versions of aws-sdk
: 2.398.0, 2.356.0, 2.350.0
Able to run on debug mode with the max-old-space-size
solution, but still unable to create a release build.
Encountering this issue when adding aws-sdk to a NodeJS app
An update: it works when I set transpileOnly: true for ts-loader.
I have the same issue on my nestjs application, when I deploy it to heroku
Faced with the same issue with Angular application. Any ideas?
@nenecmrf Use smaller 3rd party packages . I had to switch to node-ses
for sending out emails. aws-sdk-js
is just totally broken for me. Works okay locally, but then once it's deployed anywhere the memory usage blows up.
I was facing the same problem and after upgrading node from v10.15.3 to v12.18.0 the issue went away.
I was facing the same problem and after upgrading node from v10.15.3 to v12.18.0 the issue went away.
Can this be verified ?
Happy to help if it is still a persisting issue.
Will be closed if we dint have replies.
If anyone comes here looking to build a JS frontend on Amplify, it seems that it comes from the difference in the way memory is handled by node v10 vs node v12.
Check how you can add nvm use $VERSION_NODE_12
to your build settings as explained by @atlesp here https://github.com/aws-amplify/amplify-console/issues/440#issuecomment-602626451
Still having the issue when deploying Nest.js application to aws elastic beanstalk with docker file.
Dockerfile
# Build
FROM node:12
WORKDIR /usr/src/app
COPY package.json .
COPY yarn.lock .
RUN yarn
COPY . .
RUN yarn build
# Run
FROM node:12-alpine
WORKDIR /usr/src/app
COPY --from=0 /usr/src/app .
EXPOSE 80
CMD ["yarn", "start:prod"]
EB platform: Docker running on 64bit Amazon Linux 2/3.0.3
I have the same issue on my nestjs application, when I deploy it to heroku
were u able to resolve the issue?
@SaveYourTime A memory issue because of all client imports was fixed in https://github.com/aws/aws-sdk-js/pull/3398
Can you please check if this issue was fixed in version ~2.740.0
?
This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.
This was fixed in 2.740.0. It works like charm now.
Thanks @ausshadu for verifying.
Is the issue fixed in version ~2.740.0
for others?
cc @artechventure @4RGUS @Argus444 @tedi0722 @zholmes1 @SaveYourTime @aaadarshbisht
Thanks @ausshadu for verifying.
Is the issue fixed in version
~2.740.0
for others? cc @artechventure @4RGUS @Argus444 @tedi0722 @zholmes1 @SaveYourTime @aaadarshbisht
is the issue fixed your mentioned version?
Thanks in advance.
This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.
Hi @trivikr!
I still encounter the memory issue with my Nest.js application + Docker
deploy to AWS elastic beanstalk.
Here's my package.json
and Dockerfile
.
{
"dependencies": {
"@nestjs/cli": "^7.0.0",
"@nestjs/common": "^7.0.0",
"@nestjs/core": "^7.0.0",
"@nestjs/jwt": "^7.1.0",
"@nestjs/passport": "^7.1.0",
"@nestjs/platform-express": "^7.0.0",
"@nestjs/swagger": "^4.5.12",
"@nestjs/typeorm": "^7.1.0",
"@types/node": "^13.9.1",
"aws-sdk": "2.758.0",
"bcryptjs": "^2.4.3",
"class-transformer": "^0.2.3",
"class-validator": "^0.12.2",
"cookie-parser": "^1.4.5",
"dayjs": "^1.8.32",
"dotenv": "^8.2.0",
"helmet": "^3.23.3",
"mysql2": "^2.1.0",
"passport": "^0.4.1",
"passport-facebook-token": "^4.0.0",
"passport-jwt": "^4.0.0",
"passport-token-google2": "^0.1.4",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^6.5.4",
"swagger-ui-express": "^4.1.4",
"typeorm": "^0.2.25",
"typeorm-naming-strategies": "^1.1.0",
"typeorm-seeding": "^1.6.1"
},
"devDependencies": {
"@nestjs/schematics": "^7.0.0",
"@nestjs/testing": "^7.0.0",
"@types/express": "^4.17.3",
"@types/faker": "^4.1.12",
"@types/jest": "25.2.3",
"@types/multer": "^1.4.3",
"@types/passport-facebook-token": "^0.4.34",
"@types/passport-jwt": "^3.0.3",
"@types/supertest": "^2.0.8",
"@typescript-eslint/eslint-plugin": "3.0.2",
"@typescript-eslint/parser": "3.0.2",
"eslint": "7.1.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.2.5",
"jest": "26.0.1",
"lint-staged": "^10.2.11",
"prettier": "^2.0.5",
"supertest": "^4.0.2",
"ts-jest": "26.1.0",
"ts-loader": "^6.2.1",
"ts-node": "^8.6.2",
"tsconfig-paths": "^3.9.0",
"typescript": "^3.7.4"
}
}
# Build
FROM node:12
WORKDIR /usr/src/app
COPY package.json .
COPY yarn.lock .
RUN yarn
COPY . .
RUN yarn build
# Run
FROM node:12-alpine
WORKDIR /usr/src/app
COPY --from=0 /usr/src/app .
EXPOSE 80
CMD ["yarn", "start:prod"]
----------------------------------------
/var/log/eb-engine.log
----------------------------------------
2: ConstructFrame [pc: 0x13501af]
Security context: 0x025c4a8008d1 <JSObject>
3: checkSourceElementWorker(aka checkSourceElementWorker) [0x229a2f403a49] [/usr/src/app/node_modules/typescript/lib/typescript.js:~66476] [pc=0x23127cf500b8](this=0x3bea21e404b1 <undefined>,0x2bbab4127d19 <NodeObject map = 0x33ed2a9a7e9>)
4: checkVariableLikeDeclaration(aka checkVaria...
[91m 1: 0xa093f0 node::Abort() [/usr/local/bin/node]
[0m[91m 2: 0xa097fc node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
[0m[91m 3: 0xb8431e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
[0m[91m 4: 0xb84699 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
[0m[91m 5: 0xd31055 [/usr/local/bin/node]
[0m[91m 6: 0xd316e6 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node]
[0m[91m 7: 0xd3df65 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
[0m[91m 8: 0xd3ee15 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
[0m[91m 9: 0xd418cc v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
[0m[91m10: 0xd0837b v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/bin/node]
[0m[91m11: 0x1049fbe v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
[0m[91m12: 0x13cf099 [/usr/local/bin/node]
[0m[91mAborted (core dumped)
[0m[91merror Command failed with exit code 134.
[0minfo Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2020/09/23 06:31:32.136398 [WARN] failed to execute command: docker build -t aws_beanstalk/staging-app /var/app/current/, retrying...
2020/09/23 06:31:32.140268 [INFO] Running command /bin/sh -c docker build -t aws_beanstalk/staging-app /var/app/current/
2020/09/23 06:32:18.443017 [INFO] Sending build context to Docker daemon 598.5kB
Step 1/12 : FROM node:12
---> 28faf336034d
Step 2/12 : WORKDIR /usr/src/app
---> Using cache
---> a2af9b51cc56
Step 3/12 : COPY package.json .
---> Using cache
---> ed7940eed9e1
Step 4/12 : COPY yarn.lock .
---> Using cache
---> d3f3b8bdaace
Step 5/12 : RUN yarn
---> Using cache
---> 2b41ce2a4781
Step 6/12 : COPY . .
---> Using cache
---> 182b46188b29
Step 7/12 : RUN yarn build
---> Running in b07d4d39b20e
yarn run v1.22.4
$ rimraf dist
$ nest build
<--- Last few GCs --->
[40:0x4565410] 30980 ms: Mark-sweep 491.5 (498.5) -> 490.0 (495.0) MB, 266.8 / 0.0 ms (+ 250.6 ms in 54 steps since start of marking, biggest step 17.8 ms, walltime since start of marking 950 ms) (average mu = 0.327, current mu = 0.456) allocation fai[40:0x4565410] 31837 ms: Mark-sweep 491.8 (495.0) -> 490.1 (494.5) MB, 556.4 / 0.0 ms (+ 151.7 ms in 28 steps since start of marking, biggest step 21.2 ms, walltime since start of marking 857 ms) (average mu = 0.254, current mu = 0.174) allocation fai
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x13cf099]
Security context: 0x0f0853d008d1 <JSObject>
1: getTypeWithThisArgument(aka getTypeWithThisArgument) [0x16555d027779] [/usr/src/app/node_modules/typescript/lib/typescript.js:~43298] [pc=0x1d746c4f96bc](this=0x1d143ddc04b1 <undefined>,0x2eac66aa97c1 <TypeObject map = 0x3cbba8370c9>,0x1d143ddc04b1 <undefined>,0x1d143ddc04b1 <undefined>)
2: checkInterfaceDeclaration(aka checkInterfaceDeclaration) [0x16...
[91mFATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
[0m[91m 1: 0xa093f0 node::Abort() [/usr/local/bin/node]
[0m[91m 2: 0xa097fc node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
[0m[91m 3: 0xb8431e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
[0m[91m 4: 0xb84699 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
[0m[91m 5: 0xd31055 [/usr/local/bin/node]
[0m[91m 6: 0xd316e6 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node]
[0m[91m 7: 0xd3df65 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
[0m[91m 8: 0xd3ee15 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
[0m[91m 9: 0xd418cc v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
[0m[91m10: 0xd0837b v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/bin/node]
[0m[91m11: 0x1049fbe v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
[0m[91m12: 0x13cf099 [/usr/local/bin/node]
[0m[91mAborted (core dumped)
[0m[91merror Command failed with exit code 134.
[0minfo Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2020/09/23 06:32:18.445279 [ERROR] An error occurred during execution of command [app-deploy] - [Docker Specific Build Application]. Stop running the command. Error: failed to build docker image: Command /bin/sh -c docker build -t aws_beanstalk/staging-app /var/app/current/ failed with error exit status 134. Stderr:The command '/bin/sh -c yarn build' returned a non-zero code: 134
2020/09/23 06:32:18.445290 [INFO] Executing cleanup logic
2020/09/23 06:32:18.460321 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[{"msg":"Instance deployment failed to build the Docker image. The deployment failed.","timestamp":1600842738,"severity":"ERROR"},{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1600842738,"severity":"ERROR"}]}]}
2020/09/23 06:32:18.463715 [INFO] Platform Engine finished execution on command: app-deploy
2020/09/23 06:34:25.469095 [INFO] Starting...
2020/09/23 06:34:25.469164 [INFO] Starting EBPlatform-PlatformEngine
2020/09/23 06:34:25.470004 [INFO] reading event message file
2020/09/23 06:34:25.472132 [INFO] no eb envtier info file found, skip loading env tier info.
2020/09/23 06:34:25.472217 [INFO] Engine received EB command cfn-hup-exec
2020/09/23 06:34:25.618486 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:ap-northeast-1:750711200030:stack/awseb-e-imsiev4smg-stack/9aec19b0-fd65-11ea-adad-0e7aab70c3aa -r AWSEBAutoScalingGroup --region ap-northeast-1
2020/09/23 06:34:26.287344 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:ap-northeast-1:750711200030:stack/awseb-e-imsiev4smg-stack/9aec19b0-fd65-11ea-adad-0e7aab70c3aa -r AWSEBBeanstalkMetadata --region ap-northeast-1
2020/09/23 06:34:26.634058 [INFO] checking whether command tail-log is applicable to this instance...
2020/09/23 06:34:26.634072 [INFO] this command is applicable to the instance, thus instance should execute command
2020/09/23 06:34:26.634076 [INFO] Engine command: (tail-log)
2020/09/23 06:34:26.634977 [INFO] Executing instruction: GetTailLogs
2020/09/23 06:34:26.634984 [INFO] Tail Logs...
2020/09/23 06:34:26.636951 [INFO] Running command /bin/sh -c tail -n 100 /var/log/eb-engine.log
Have the same problem Nest.js application + Docker
deploy to AWS ec2.
I fixed it.
The import method of service had to be changed. For example S3
instead
import { S3 } from 'aws-sdk';
you must use
import S3 = require("../../node_modules/aws-sdk/clients/s3");
i also face the same issue when i import the aws-sdk library my application memory is ~600MB and if i remove the import then my application memory is 254MB . im using node v12.18.3 my project is express typescript
@amitgilad3 I have the same setup and I fixed it by using this import (aws-sdk 2.769.0)
import S3 from 'aws-sdk/clients/s3';
Is the problem fixed when you import just the clients?
This issue is also well addressed in JS SDK V3 which is under gamma release.
This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.
I'm still getting this. I'm using "aws-sdk": "2.767.0"
with expo 38 (bare workflow)
System:
OS: Linux 5.4 Ubuntu 18.04.5 LTS (Bionic Beaver)
CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Memory: 5.59 GB / 15.10 GB
Shell: Unknown
Binaries:
Node: 12.13.0 - /usr/local/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.12.0 - /usr/local/bin/npm
Watchman: Not Found
SDKs:
Android SDK:
Android NDK: 20.0.5594570
IDEs:
Android Studio: Not Found
Languages:
Java: Not Found
Python: 2.7.17 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: ~16.11.0 => 16.11.0
react-native: 0.62.2 => 0.62.2
I'm running node v12.13.0
I've tried modifying my .bashrc to include this line: export NODE_OPTIONS=--max_old_space_size=4096
I've tried modifying my app/build.gradle:
project.ext.react = [
enableHermes: false,
nodeExecutableAndArgs: ["node", "--max-old-space-size=8192"],
inputExcludes: ["node_modules/aws-sdk/dist/aws-sdk-react-native.js"]
]
I've modified my package.json to include:
"babel": {
"ignore": [
"node_modules/aws-sdk/dist/aws-sdk-react-native.js"
]
},
I've tried using both import AWS from 'aws-sdk/dist/aws-sdk-react-native';
and var AWS = require('aws-sdk/dist/aws-sdk-react-native');
I've tried increasing my Android Studio memory - IDE max heap size, Gradle daemon max heap size, and Kotlin daemon max heap size are all at the maximum 4096mb.
Something that I haven't seen suggested here is editing your gradle.properties to include:
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx4096m
The above seems to help produce release builds more reliably (but only just)
Since installing aws-sdk
, my release builds now take 2-3 times as long (at least) and fail 80% of the time, if they don't completely lock up my laptop.
Unfortunately using another package is not an option for me as I need to put records directly into a Kinesis stream.
Ultimately, I don't understand why I need to increase the maximum memory required to build my app just to accommodate this specific SDK.
Hopefully v3 will resolve this issue but it's still a release candidate and so not an option for production use.
@amitgilad3 I have the same setup and I fixed it by using this import (aws-sdk 2.769.0)
import S3 from 'aws-sdk/clients/s3';
Can confirm! Cut around 350 mb on nextjs, "aws-sdk": "^2.784.0",
@amitgilad3 I have the same setup and I fixed it by using this import (aws-sdk 2.769.0)
import S3 from 'aws-sdk/clients/s3';
here is the solution to the problem with docker + nestjs
Environment
React Native Environment Info: System: OS: macOS 10.14 CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz Memory: 2.16 GB / 16.00 GB Shell: 5.3 - /bin/zsh Binaries: Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node Yarn: 1.16.0 - ~/.nvm/versions/node/v10.15.3/bin/yarn npm: 6.9.0 - ~/.nvm/versions/node/v10.15.3/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1 Android SDK: API Levels: 25, 27, 28 Build Tools: 27.0.3, 28.0.2, 28.0.3 IDEs: Android Studio: 3.2 AI-181.5540.7.32.5056338 Xcode: 10.1/10B61 - /usr/bin/xcodebuild npmPackages: react: 16.8.3 => 16.8.3 react-native: 0.59.8 => 0.59.8 npmGlobalPackages: react-native-cli: 2.0.1
Description
I am using aws-sdk (https://github.com/aws/aws-sdk-js) in my react-native project. After upgrading v0.56.1 to v0.59.8, metro bundler shows error below.
Reproducible Demo
I tested on vanilla RN project (created by react-native init, and added only aws-sdk) and it shows same result.
https://github.com/artechventure/rn59AwsDemo