I'm trying to minify a 24MB JavaScript file, but after about 10 minutes of runtime, the script exits with an error about running out of memory. Are there any flags that can help? I'm running Windows 7 64-bit with 16GB physical memory.
C:\projects\test\js>uglifyjs -o ffmpeg.min.js ffmpeg.js
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
This worked for me:
"scripts": {
"ugly": "node --max_old_space_size=4096 ./node_modules/uglify-js/bin/uglifyjs ffmpeg.js -c -o ffmpeg.min.js"
},
Related
I have a TypeScript function defined at src/index.ts for AWS Lambda below. For the purpose of this question, it simply sends a JSON body with a "hello world" statement. While running the docker container locally and making a file change, the lambda return value should change accordingly.
import { Context, APIGatewayProxyResult, APIGatewayEvent } from "aws-lambda";
export const handler = async (
event: APIGatewayEvent,
context: Context
): Promise<APIGatewayProxyResult> => {
return {
statusCode: 200,
headers: {
"content-type": "application/json",
},
body: JSON.stringify({ text: "hello world" })
};
};
My yarn develop command is equal to the following shell command:
esbuild src/index.ts --watch --bundle --minify --sourcemap --platform=node --target=es2020 --outfile=build/index.js
Paired with yarn develop, I use the following Dockerfile.dev to set up my local development environment:
FROM public.ecr.aws/lambda/nodejs:16
RUN npm install --global yarn
WORKDIR /usr/app
RUN yarn install --frozen-lockfile
# where transpiled index.js is pointed.
VOLUME /var/task/build
CMD [ "build/index.handler" ]
I use the following Makefile with a develop target to run my lambda locally.
SHELL := /bin/bash
APPNAME = hello-world
.PHONY: develop
develop:
#docker build -f Dockerfile.dev -t $(APPNAME):dev .
#docker run -p 9000:8080 -v $(shell pwd)/build:/var/task/build $(APPNAME):dev & yarn develop
Lastly, this is how I test my lambda output locally:
cfaruki#hello-world[main] curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}' | jq .
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 102 100 100 100 2 161 3 --:--:-- --:--:-- --:--:-- 166
{
"statusCode": 200,
"headers": {
"content-type": "application/json"
},
"body": "{\"text\":\"hello world\"}"
}
With this context in mind, the issue I run into is what happens when I make a file change. If I change the response body to anything else, the file change is acknowledged in my terminal output. But the resultant output of my AWS lambda does not change.
docker run -p 9000:8080 -v /path/to/hello-world/build:/var/task/build hello-world:dev & yarn develop
yarn run v1.22.19
$ esbuild src/index.ts --watch --bundle --minify --sourcemap --platform=node --target=es2020 --outfile=build/index.js
01 Feb 2023 14:54:54,725 [INFO] (rapid) exec '/var/runtime/bootstrap' (cwd=/usr/app, handler=)
[watch] build finished, watching for changes...
01 Feb 2023 14:55:00,290 [INFO] (rapid) extensionsDisabledByLayer(/opt/disable-extensions-jwigqn8j) -> stat /opt/disable-extensions-jwigqn8j: no such file or directory
01 Feb 2023 14:55:00,290 [WARNING] (rapid) Cannot list external agents error=open /opt/extensions: no such file or directory
START RequestId: 5b738544-3713-4b41-86f8-7eca4355d230 Version: $LATEST
END RequestId: 5b738544-3713-4b41-86f8-7eca4355d230
REPORT RequestId: 5b738544-3713-4b41-86f8-7eca4355d230 Init Duration: 1.35 ms Duration: 1143.56 ms Billed Duration: 1144 ms Memory Size: 3008 MB Max Memory Used: 3008 MB
[watch] build started (change: "src/index.ts") // <----- HERE IS THE CHANGE
[watch] build finished
I have validated that any change to my src/index.ts results in a change in build/index.js. I validate this by SSHing into the docker container and printing the file contents of build/index.js:
docker exec -it <CONTAINER-ID> /bin/bash
cat /var/task/build/index.js
It seems to me that the issue I am encountering is that the AWS Lambda docker image does not support live reloading of the function on file change. If that is the case, is there a way I can affect this behavior without adding another dependency to my development workflow?
Or is my only option to destroy and rebuild my docker image each time I make a file change? I am aware that docker-compose simplifies the process of rebuilding docker images. But I want to minimize the amount of configuration required by my project.
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
error Command failed with exit code 1.
My Docker File code contains
FROM node:13.12.0-alpine as build
WORKDIR /home/app
COPY package.json /home/app/
COPY package-lock.json /home/app/
COPY lerna.json /home/app/
COPY yarn.lock /home/app
COPY babel.config.js /home/app
COPY shared /home/app/shared
COPY projects/tt-core /home/app/projects/tt-core
RUN yarn install --frozen-lockfile --non-interactive --production=false --ignore-scripts
# RUN yarn build:tt-core
#to run in development mode
EXPOSE 3000
CMD ["yarn", "start:tt-core"]
I am facing this error every time when I run the azure devops build with self hosted agent that run with virtual machine scale set (vmss). There is still no clue that why this error is happening. I have added the variable.
NODE_OPTIONS --max_old_space_size=36864
But still it is giving me error whenever I run the new Build.
JS stacktrace
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed.
Exit code: 1
Command: /usr/local/bin/node
Arguments: /opt/yarn-v1.22.5/lib/cli.js run build
Directory: /app/projects/tt-core
Output:
I have tried to increase the old space from 8 GB to 36 GB but still it's giving me same error every time I build the pipeline.
when I type this code ( npm run moralis:sync), I run into this error:
my-app#0.1.0 moralis:sync
moralis-admin-cli connect-local-devchain --chain hardhat --moralisSubdomain cxdjddn5lxdh.usemoralis.com --frpcPath ./frp/frpc
Starting connection to Hardhat
exec error: Error: Command failed: "./frp/frpc" http -s cxdjddn5lxdh.usemoralis.com:7000 -t GCqiUSu6wG -l 8545 -d cxdjddn5lxdh.usemoralis.com
'"./frp/frpc"' is not recognized as an internal or external command,
operable program or batch file.
Hello which version of frp have you installed? Make sure your fprcPath is correct.
Two related threads:
https://forum.moralis.io/t/unable-to-connect-hardhat-local-node-to-moralis/17154
https://forum.moralis.io/t/which-frpc-file-to-download-to-connect-moralis-server-to-blockchain/17294/15
If you have more questions or issues with this, you can post on the Moralis forum: https://forum.moralis.io
I'm trying to run Appium from command line but getting error 800A138F - Microsoft JScript runtime error.
I have created a BATCH file containing the following data.
ECHO
START "C:\Program Files (x86)\Appium\node.exe" "C:\Program Files (x86)\Appium\node_modules\appium\lib\server\main.js" --address 127.0.0.1 --port 4723 --platform-name Android --platform-version 23 --automation-name Appium --log-no-color
Then, the windows script host pop up error appears.
I have been trying to install the MEAN stack using the following tutorial:
http://www.bossable.com/303/install-mean-stack/#comment-1526
I am using webstorm and MongoDB.
However I have been unsuccessful and I keep getting errors. Everytime I connect to localhost:3000 I get the following error:
C:\meanproject>grunt
Running "jshint:all" (jshint) task
>> 55 files lint free.
Running "csslint:all" (csslint) task
>> 2 files lint free.
Running "concurrent:default" (concurrent) task
Running "nodemon:dev" (nodemon) task
Running "watch" task
Waiting...
[nodemon] v1.2.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: app/views/**/*.* gruntfile.js server.js config/**/*.js app/*
*/*.js
[nodemon] starting `node --debug server.js`
Debugger listening on port 5858
Application loaded using the "development" environment configuration
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
MEAN.JS application started on port 3000
C:\meanproject\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection
\base.js:246
throw message;
^
Error: Error setting TTL index on collection : sessions
at C:\meanproject\node_modules\connect-mongo\lib\connect-mongo.js:169:23
at C:\meanproject\node_modules\mongoose\node_modules\mongodb\lib\mongodb\db.
js:1499:46
at C:\meanproject\node_modules\mongoose\node_modules\mongodb\lib\mongodb\db.
js:1632:20
at C:\meanproject\node_modules\mongoose\node_modules\mongodb\lib\mongodb\cur
sor.js:170:22
at C:\meanproject\node_modules\mongoose\node_modules\mongodb\lib\mongodb\cur
sor.js:714:39
at Cursor.close (C:\meanproject\node_modules\mongoose\node_modules\mongodb\l
ib\mongodb\cursor.js:1009:5)
at commandHandler (C:\meanproject\node_modules\mongoose\node_modules\mongodb
\lib\mongodb\cursor.js:714:21)
at C:\meanproject\node_modules\mongoose\node_modules\mongodb\lib\mongodb\db.
js:1905:9
at Server.Base._callHandler (C:\meanproject\node_modules\mongoose\node_modul
es\mongodb\lib\mongodb\connection\base.js:453:41)
at C:\meanproject\node_modules\mongoose\node_modules\mongodb\lib\mongodb\con
nection\server.js:488:18
at MongoReply.parseBody (C:\meanproject\node_modules\mongoose\node_modules\m
ongodb\lib\mongodb\responses\mongo_reply.js:68:5)
at null.<anonymous> (C:\meanproject\node_modules\mongoose\node_modules\mongo
db\lib\mongodb\connection\server.js:446:20)
at emit (events.js:107:17)
at null.<anonymous> (C:\meanproject\node_modules\mongoose\node_modules\mongo
db\lib\mongodb\connection\connection_pool.js:207:13)
at emit (events.js:110:17)
at Socket.<anonymous> (C:\meanproject\node_modules\mongoose\node_modules\mon
godb\lib\mongodb\connection\connection.js:440:22)
[nodemon] app crashed - waiting for file changes before starting...
How would I go about solving this?
You need to run the mongodb.exe file first. After successfully starting mongodb, you need to navigate into your project folder and run 'grunt'. If it shows you a error list of modules not found, you need to install those modules globally with npm. That will solve the problem for you. However, please note that bossable.com tutorial is for 0.3 mean stack boiler plate. They have upgraded their version to 0.4.1 now. Follow the Meanjs documentation
for latest information.