Azure NodeJS Web Service exists with status code null and signal SIGSEGV - node.js

I'm trying to deploy a NodeJS application to an Azure web service (Node version 10.14, Azure B1 plan), however, when I run the application, it always exists with status null and signal SIGSEGV.
There were no errors outputted. I tried deploying the same code to Heroku and there were no issues at all.
I tried using the segfault-handler module in hopes that it will tell what is wrong, but the only thing that it logs is:
PID 147 received SIGSEGV for address: 0x2c26
Any ideas what might cause this? One thing I was able to find that it might be related to native modules, but I still don't know which one might cause this.
EDIT
The Azure web service uses Linux OS and not Windows.
Modules used:
"dependencies": {
"apidoc": "^0.17.7",
"applicationinsights": "^1.3.1",
"bcrypt": "^3.0.5",
"chalk": "^2.4.2",
"concurrently": "^3.6.1",
"dotenv": "^6.2.0",
"excel4node": "^1.7.1",
"express": "^4.17.1",
"express-sslify": "^1.2.0",
"firebase-admin": "^7.2.0",
"get-port": "^4.2.0",
"is-json": "^2.0.1",
"joi": "^14.3.1",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.11",
"mailgun-js": "^0.22.0",
"mkdirp": "^0.5.1",
"moment": "^2.24.0",
"morgan": "^1.9.1",
"node-cache": "^4.2.0",
"node-cleanup": "^2.1.2",
"node-schedule": "^1.3.1",
"nodemon": "^1.19.0",
"number-to-words": "^1.2.4",
"pdf-to-base64": "^1.0.2",
"pdfkit": "^0.9.1",
"pg": "^7.9.0",
"pug": "^2.0.3",
"rate-limiter-flexible": "^1.0.2",
"request": "^2.88.0",
"request-promise-native": "^1.0.7",
"segfault-handler": "^1.2.0",
"sequelize": "^5.8.7",
"socketcluster": "^14.3.3",
"socketcluster-client": "^14.2.2",
"socketcluster-server": "^14.4.0",
"systeminformation": "^4.0.15",
"twilio": "^3.30.0",
"umzug": "^2.2.0",
"uuid": "^3.3.2"
},
"devDependencies": {
"#types/chai": "^4.1.7",
"#types/chalk": "^2.2.0",
"#types/cookie-parser": "^1.4.1",
"#types/dotenv": "^6.1.0",
"#types/express": "^4.16.0",
"#types/joi": "^14.3.3",
"#types/lodash": "^4.14.107",
"#types/mocha": "^5.2.6",
"#types/moment": "^2.13.0",
"#types/morgan": "^1.7.35",
"#types/node": "^9.6.5",
"#types/request-promise": "^4.1.42",
"#types/serialize-javascript": "^1.3.2",
"#types/sinon": "^7.0.11",
"#types/uuid": "^3.4.3",
"casual": "^1.6.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"mocha": "^5.2.0",
"sinon": "^7.2.3"
}

As you said, if there are few node modules related to native apis like Win32k.sys, it will be terminated immediately by Azure Web App sandbox once run.
Therefore, the possible reason may be these limits and restrictions described in sandbox secure environment, such as below.
Please inspect your used modules carefully. Hope it helps.

Related

mocha not recognizing structuredClone is not defined

I'm using visual studio code with node v18.
I use structuredClone in my application and it runs fine but when it comes to running a test I get
"ReferenceError: structuredClone is not defined"
I don't know how mocha works, but is it for some reason using an older version of node or is there some other dependency creating an issue?
"dependencies": {
"#sendgrid/mail": "^7.6.2",
"#types/chai": "^4.3.1",
"#types/express": "^4.17.13",
"#types/mocha": "^9.1.1",
"#types/node": "^18.0.0",
"#types/npm": "^7.19.0",
"bcrypt": "^5.0.1",
"body-parser": "^1.19.2",
"chai": "^4.3.6",
"connect-flash": "^0.1.1",
"cookie-parser": "^1.4.6",
"dotenv": "^16.0.0",
"eventemitter2": "^6.4.5",
"express": "^4.17.3",
"express-validator": "^6.14.0",
"jsdom": "^20.0.0",
"jsonwebtoken": "^8.5.1",
"marked": "^4.0.12",
"memory-cache": "^0.2.0",
"mocha": "^10.0.0",
"mssql": "^8.0.2",
"sanitize-html": "^2.7.0",
"validator": "^13.7.0",
"xsg.spider": "file:./../spider"
},
"devDependencies": {
"#types/bcrypt": "^5.0.0",
"#types/connect-flash": "^0.0.37",
"#types/cookie-parser": "^1.4.2",
"#types/dompurify": "^2.3.3",
"#types/jsdom": "^16.2.14",
"#types/jsonwebtoken": "^8.5.8",
"#types/marked": "^4.0.3",
"#types/memory-cache": "^0.2.2",
"#types/mssql": "^7.1.5",
"#types/passport-local": "^1.0.34",
"#types/sanitize-html": "^2.6.2",
"#types/validator": "^13.7.2",
"nyc": "^15.1.0",
"ts-node": "^10.7.0",
"typescript": "^4.6.4"
}
It's probably a bug, as a turnaround to deep clone your object, you can use JSON.parse & JSON.stringify:
if (global.structuredClone)
clonedObject = structuredClone(object)
else
clonedObject = JSON.parse(JSON.stringify(object))

How do I recompile my NodeJS app to update files? Why are images encoded? Why is the workflow so bad?

Beginner question. Got an app running on a server, it is a complex one.
Now in the client directory there is an index file called index.html (I thought node was using express/routed, what is it doing there)
module.exports = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
},
// cheap-module-eval-source-map is faster for development
//devtool: '#cheap-module-eval-source-map',
devtool: '#source-map',
plugins: [
new webpack.DefinePlugin({
'process.env': config.dev.env
}),
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
}),
new FriendlyErrorsPlugin()
]
})
1) Why are the image URLS encoded? And I can instead paste absolute URLS? This is not developer friendly, makes me want to abandon Node right away if they dont have proper views and need extra steps
<img class="color loader-box-image" data-v-553e61a2="" alt=. src="data:image/png;base64,iVBOR....." LONG STRING />
2) Ok so assume I am updating the index file in there, it does not update the live page. I have to assume the index file is either cached or Node itself is caching some version of it. Is the index.html just a static file? And if not, why?
What are best practices to get a simplified workflow?
Thank you
Edit: I understand node itself is acting like a webserver (JS based) and that routes have to be established. How do static files play into this?
"dependencies": {
"axios": "^0.18.0",
"babel-plugin-transform-react-jsx": "^6.24.1",
"bootstrap": "^4.0.0",
"bootstrap-social": "^5.1.1",
"dependency-list": "^0.2.2",
"jquery": "^3.2.1",
"jquery-sparkline": "^2.4.0",
"moment": "^2.20.1",
"react-stockcharts": "^0.6.1",
"sitemap": "^1.13.0",
"socicon": "^3.0.5",
"vee-validate": "^2.0.2",
"vue": "^2.5.2",
"vue-authenticate": "^1.3.4",
"vue-axios": "^2.0.2",
"vue-event-calendar": "git+https://git#github.com/adi-darachi/vue-event-calendar.git",
"vue-multiselect": "^2.0.8",
"vue-resource": "^1.3.4",
"vue-router": "^3.0.1",
"vue-search-select": "^2.5.0",
"vue-social-sharing": "^2.3.3",
"vue-socket.io": "^2.1.1-a",
"vue-tweet-embed": "^2.0.0",
"vue-virtual-scroll-list": "^1.2.4",
"vuetrend": "^0.2.3",
"vuex": "^3.0.1"
},
> "devDependencies": {
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-eslint": "^7.1.1",
"babel-loader": "^7.1.1",
"babel-plugin-istanbul": "^4.1.1",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"bootstrap-vue": "^1.4.1",
"chai": "^4.1.2",
"chalk": "^2.0.1",
"chromedriver": "^2.27.2",
"compression-webpack-plugin": "^1.1.11",
"connect-history-api-fallback": "^1.3.0",
"copy-webpack-plugin": "^4.0.1",
"cross-env": "^5.0.1",
"cross-spawn": "^5.0.1",
"css-loader": "^0.28.0",
"eslint": "^3.19.0",
"eslint-config-standard": "^10.2.1",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.7.1",
"eslint-plugin-html": "^3.0.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^3.0.1",
"eventsource-polyfill": "^0.9.6",
"express": "^4.14.1",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^2.30.1",
"http-proxy-middleware": "^0.17.3",
"inject-loader": "^3.0.0",
"karma": "^1.4.1",
"karma-coverage": "^1.1.1",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.2",
"karma-phantomjs-shim": "^1.4.0",
"karma-sinon-chai": "^1.3.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "0.0.31",
"karma-webpack": "^2.0.2",
"mocha": "^3.2.0",
"nightwatch": "^0.9.12",
"npm": "^5.5.1",
"offline-plugin": "^4.9.0",
"opengraph-html-webpack-plugin": "^1.0.0",
"opn": "^5.1.0",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^1.2.0",
"phantomjs-prebuilt": "^2.1.14",
"portfinder": "^1.0.13",
"rimraf": "^2.6.0",
"selenium-server": "^3.0.1",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"sinon": "^4.0.0",
"sinon-chai": "^2.8.0",
"sitemap-webpack-plugin": "^0.6.0",
"url-loader": "^0.5.8",
"vue-loader": "^13.3.0",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2",
"webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-middleware": "^1.12.0",
"webpack-hot-middleware": "^2.18.2",
"webpack-merge": "^4.1.0"
},
You are conflating node and webpack. Node isn't encoding those images, one of the webpack plugins is and is doing so to save you a network request.
Additionally, you said in one of your comments:
Thanks, good advice but I cant. I simply need to modify some CSS and
swap the logo - that should be simple enough but for that I need to
get a basic understanding of NodeJS in very little time. I dont get
why there is an index.html file in the first place when I learned that
Node uses dedicated directories for files previously
You are using html-webpack-plugin. That generates the index.html file for you. Don't modify the generated file, modify the configuration that generates the file. Otherwise you're going to get a regression. Read the documentation on that plugin and you should be able to figure out where the logo is being drawn from in your code.
The problem is that this some sort of pre-built starter project, and the developer made some decisions which you don't fully understand yet.
Since this strategy has frustrated you, I recommend trying a different strategy: build the simplest possible project that you possibly can, using as few libraries as possible, and build out from there. Good luck!

Can't execute Electron app on other devices after packaging(edit: nfc library is the cause)

I have an electron app that uses Vue.js.
I ran electron-packager and got a nice looking folder. When I run the executable on my own computer it works. The window is displayed, and everything works great.
However, if I run it at any other winx64 computer it fails.
No error is displayed, running through cmd doesn't display anything and background processes are started, but the window doesn't open.
So I thought maybe it's a dependency issue. However, I have both dependencies installed. I have googled for ages but cant find out what the issue is.
"dependencies": {
"axios": "^0.18.0",
"electron-log": "^2.2.14",
"electron-logger": "^0.0.3",
"electron-packager": "^12.1.0",
"moment": "^2.22.1",
"nfc-pcsc": "^0.6.2",
"vue": "^2.0.1",
"vue-config": "^1.0.0",
"vue-momentjs": "^0.1.2",
"vue-router": "^3.0.1",
"vuetify": "^1.0.17"
},
"devDependencies": {
"#babel/core": "^7.0.0-beta.46",
"#babel/plugin-proposal-class-properties": "^7.0.0-beta.46",
"#babel/polyfill": "^7.0.0-beta.46",
"#babel/preset-env": "^7.0.0-beta.46",
"#babel/register": "^7.0.0-beta.46",
"babel-loader": "8.0.0-beta.2",
"cross-env": "^5.1.4",
"css-loader": "^0.28.11",
"devtron": "^1.4.0",
"electron": "^2.0.0",
"electron-debug": "^1.5.0",
"electron-rebuild": "^1.7.3",
"file-loader": "^1.1.11",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^3.2.0",
"rimraf": "^2.6.2",
"vue-devtools": "^3.1.9",
"vue-loader": "^15.0.9",
"vue-template-compiler": "^2.5.16",
"webpack": "^4.8.0",
"webpack-cli": "^2.1.3",
"webpack-dev-server": "^3.1.4",
"webpack-merge": "^4.1.2"
}
Edit:
I found out the nfc-pcsc library i'm using is the root of my problem.. No idea why and how to solve it... Im gonna dig in a bit further. Any idea's wy?

express application upload to beanstalk aborts the deployment process

What I am trying to do is create zip folder of the application and upload it to elastic beanstalk. But somehow it fails and gives me the following error:
[Instance: 'name] Command failed on instance. Return code: 1 Output: (TRUNCATED).../opt/elasticbeanstalk/containerfiles/ebnode.py", line 180, in npm_install raise e subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v6.12.2-linux-x64/bin/npm', '--production', 'rebuild']' returned non-zero exit status 1. Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
The package.json for that project is as shown below:
"dependencies": {
"#google/maps": "^0.4.5",
"aws-sdk": "^2.199.0",
"bcrypt": "^1.0.2",
"bluebird": "^3.5.0",
"body-parser": "^1.13.3",
"busboy-body-parser": "^0.3.0",
"describe": "^1.2.0",
"dotenv": "^4.0.0",
"express": "^4.13.3",
"express-validator": "^3.2.1",
"fcm-push": "^1.1.2",
"file-system": "^2.2.2",
"firebase-admin": "^4.2.0",
"jsonwebtoken": "^7.3.0",
"mailgun-js": "^0.13.1",
"mongoose": "^4.8.4",
"morgan": "^1.8.1",
"multer": "^1.3.0",
"node-schedule": "^1.2.5",
"nodemailer": "^3.1.4",
"passport": "^0.4.0",
"passport-http-bearer": "^1.0.1",
"path": "^0.12.7",
"randomstring": "^1.1.5",
"s3-image-uploader": "^1.0.7",
"sqs-consumer": "^3.8.0",
"stripe": "^4.17.0",
"twilio": "^3.7.0",
"useragent": "^2.2.1",
"utf8": "^2.1.2",
"uuid": "^3.0.1",
"winston": "^2.3.1",
"winston-daily-rotate-file": "^1.4.6"
},
"devDependencies": {
"chai": "^4.1.2",
"chai-http": "^3.0.0",
"mocha": "^3.4.2",
"nodemon": "^1.11.0"
}
What am I missing in my deployment process?
['/opt/elasticbeanstalk/node-install/node-v6.12.2-linux-x64/bin/npm', '--production', 'rebuild'] if failing.
Running NPM as part of the deploy process can be problematic especially if you have not shrink wrapped the dependancies.
You may be able to see the specific package install problem on the instance in /var/log/eb-activity.log (eb ssh to the instance)
Can you run npm production locally with an empty node_modules directory?

Deploy Django/React application heroku

I have deployed django app on heroku, and everything is fine, no errors, etc. I'm using react on frontend, and I want to do npm install, gulp build so I can configurate my app properly.
I can not run heroku run npm install, all I have is bash: npm: command not found, and I suppose that is ok because I need to trigger it somehow when he is building the app on the server, so I've modify my package.json like this:
{
"name": "Test app",
"version": "1.0.0",
"description": "Testing",
"main": "bundle.js",
"scripts": {
"postinstall": "npm install"
},
"dependencies": {
"bootstrap": "^3.3.7",
"babel-preset-es2015": "^6.1.2",
"babel-preset-react": "^6.1.2",
"babelify": "^7.2.0",
"browser-sync": "^2.10.0",
"browserify": "^12.0.1",
"browserify-shim": "^3.8.11",
"classnames": "^2.2.0",
"core-util-is": "^1.0.1",
"del": "^2.1.0",
"flux": "^2.1.1",
"gulp-autoprefixer": "^3.1.0",
"gulp-bless": "^3.0.1",
"gulp-connect": "^2.2.0",
"gulp-html-replace": "^1.5.4",
"gulp-if": "^2.0.0",
"gulp-insert": "^0.5.0",
"gulp-livereload": "^3.8.1",
"gulp-load-plugins": "^1.1.0",
"gulp-minify-css": "^1.2.1",
"gulp-rename": "^1.2.2",
"gulp-sass": "^2.1.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-sync": "^0.1.4",
"gulp-uglify": "^1.4.2",
"history": "^1.13.0",
"keymirror": "^0.1.1",
"lodash": "^3.10.1",
"react": "^0.14.2",
"react-addons": "^0.9.0",
"react-bootstrap": "^0.27.3",
"react-dom": "^0.14.2",
"react-mixin": "^3.0.3",
"react-router": "^1.0.0",
"react-style": "^0.5.5",
"reqwest": "^2.0.5",
"rimraf": "^2.4.3",
"run-sequence": "^1.1.4",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"watchify": "^3.6.0",
"when": "^3.7.4"
},
"devDependencies": {
"babel-preset-es2015": "^6.1.2",
"babel-preset-react": "^6.1.2",
"babelify": "^7.2.0",
"browser-sync": "^2.10.0",
"browserify": "^12.0.1",
"browserify-shim": "^3.8.11",
"classnames": "^2.2.0",
"core-util-is": "^1.0.1",
"del": "^2.1.0",
"flux": "^2.1.1",
"gulp-autoprefixer": "^3.1.0",
"gulp-bless": "^3.0.1",
"gulp-connect": "^2.2.0",
"gulp-html-replace": "^1.5.4",
"gulp-if": "^2.0.0",
"gulp-insert": "^0.5.0",
"gulp-livereload": "^3.8.1",
"gulp-load-plugins": "^1.1.0",
"gulp-minify-css": "^1.2.1",
"gulp-rename": "^1.2.2",
"gulp-sass": "^2.1.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-sync": "^0.1.4",
"gulp-uglify": "^1.4.2",
"history": "^1.13.0",
"keymirror": "^0.1.1",
"lodash": "^3.10.1",
"react": "^0.14.2",
"react-addons": "^0.9.0",
"react-bootstrap": "^0.27.3",
"react-dom": "^0.14.2",
"react-mixin": "^3.0.3",
"react-router": "^1.0.0",
"react-style": "^0.5.5",
"reqwest": "^2.0.5",
"rimraf": "^2.4.3",
"run-sequence": "^1.1.4",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"watchify": "^3.6.0",
"when": "^3.7.4"
},
"engines": {
"node": "8.0.0",
"npm": "5.0.4"
},
"author": "",
"license": ""
}
But that still does not trigger npm install process on deployment, so can any one help me understand how can I configurate this properly?
This is my Procfile:
web: python manage.py runserver 0.0.0.0:$PORT --noreload
worker: python worker.py
Heroku supports different server-side languages via buildpacks:
Buildpacks are responsible for transforming deployed code into a slug, which can then be executed on a dyno. Buildpacks are composed of a set of scripts, and depending on the programming language, the scripts will retrieve dependencies, output generated assets or compiled code, and more.
Since the Python part of your application seems to be installing correctly Heroku must be detecting it as a Python application (because it includes a requirements.txt file) or you have configured it as one manually. In many cases a single buildpack is sufficient.
However, since you are also using Node.js you should enable a second buildpack:
There are many scenarios in which a single buildpack is not sufficient when building an application. This includes cases when you need to:
Run a buildpack for each language your app uses. For example, run a JavaScript buildpack for assets and a Ruby buildpack for your application.
The basic flow looks like this (using the Heroku CLI on your development machine):
heroku buildpacks:set heroku/python
heroku buildpacks:add --index 2 heroku/nodejs
The links I provided above contain many more details. I recommend reading both of them in their entirety.

Resources