Socket
Socket
Sign inDemoInstall

node-oom-heapdump

Package Overview
Dependencies
68
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.1-beta to 3.0.1

.github/workflows/publish-native-assets-to-github-releases.yml

18

CHANGELOG.md

@@ -1,12 +0,12 @@

09-02-2022 Paul Rütter
10-02-2022 Paul Rütter
- 3.0.1
- Fixed building native artifacts on Windows, thanks spmiller! https://github.com/blueconic/node-oom-heapdump/issues/22
10-02-2022 Paul Rütter
- 3.0.0
- Updated dependencies to resolve https://github.com/blueconic/node-oom-heapdump/issues/19
- Removed `gc-stats` as it was not used a lot anymore (breaking change) and contained security issues.
- Removed creating heapdumps on out of memory, as this is superseeded by native node functionality.
- Remove unused dependencies and native code.
- Added Node 16 support (by merging https://github.com/blueconic/node-oom-heapdump/pull/20, Thanks Simon Abbott!).
This fixes a recursion issue.
- Removed "GC_MONITORING" at it relied on `gc-stats`, which is no longer maintained (and contained security issues)
- Updated `node-pre-gyp` to `@mapbox/node-pre-gyp` so security issues are mitigated
21-12-2020 Paul Rütter
- 2.2.0
- Updated ini
12-10-2020 Paul Rütter

@@ -13,0 +13,0 @@ - 2.1.0

@@ -84,2 +84,9 @@ let nodeOomLib = require("./lib");

function parseOptions(options) {
if (options.heapdumpOnOOM === undefined) {
options.heapdumpOnOOM = true;
}
if (options.OOMImplementation === undefined) {
// default is the "new" implementation
options.OOMImplementation = "NATIVE_HOOK";
}
if (options.port === undefined) {

@@ -90,2 +97,5 @@ options.port = 9229;

}
if (options.path === undefined) {
options.path = "OoM-pid-" + process.pid;
}
if (options.addTimestamp === undefined) {

@@ -92,0 +102,0 @@ options.addTimestamp = false;

@@ -10,2 +10,9 @@ let cp = require("child_process");

this._busy = false;
this._count = 0;
if (this._opts.heapdumpOnOOM) {
if (options.OOMImplementation === "NATIVE_HOOK") {
require('bindings')('node_oom_heapdump_native.node').call(this._getHeapSnapshotPath(this._opts.path), this._opts.addTimestamp);
}
}
}

@@ -12,0 +19,0 @@

{
"name": "node-oom-heapdump",
"version": "3.0.1-beta",
"description": "Create a heap snapshot or CPU profile on request, off-process through the DevTools protocol",
"version": "3.0.1",
"description": "Create a V8 heap snapshot when an \"Out of Memory\" error occurs, or create a heap snapshot or CPU profile on request.",
"main": "index.js",
"scripts": {
"dummy": "node -e \"process.exit(0)\"",
"api-publish-beta": "npm publish --tag beta"
"rebuild": "node-pre-gyp install --build-from-source",
"install": "node-pre-gyp install --fallback-to-build",
"test": "node --max_old_space_size=80 --inspect ./tests/oom_app.js",
"dummy": "node -e \"process.exit(0)\""
},

@@ -14,4 +16,9 @@ "repository": {

},
"binary": {
"module_name": "node_oom_heapdump_native",
"module_path": "./build/Release",
"host": "https://github.com/blueconic/node-oom-heapdump/releases/download/{version}"
},
"engines": {
"node": ">=14.0.0"
"node": ">=7.0.0"
},

@@ -37,6 +44,9 @@ "keywords": [

"dependencies": {
"chrome-remote-interface": "^0.31.2",
"@mapbox/node-pre-gyp": "^1.0.8",
"bindings": "^1.5.0",
"chrome-remote-interface": "^0.28.2",
"nan": "^2.14.2",
"require-main-filename": "^2.0.0",
"ws": "^8.5.0"
"ws": "^7.4.6"
}
}
[![TravisCI Build Status](https://travis-ci.org/blueconic/node-oom-heapdump.svg?branch=master)](https://travis-ci.org/blueconic/node-oom-heapdump)
# node-oom-heapdump
Node module that can create heapdumps and CPU profiles on request like 'v8-profiler', but does this off-process so it doesn't interfere with execution of the main process.
Node module which will create a V8 heap snapshot right before an "Out of Memory" error occurs.
Tested on Node.js 7.x, 8.x, 9.x, 10.x, 11.x, 12.x, 13.x, 14.x and 16.x.
No support for Node.js < 7.0 at the moment (although this can be fixed if needed).
It can also create heapdumps and CPU profiles on request like 'v8-profiler', but does this off-process so it doesn't interfere with execution of the main process.
Tested on Node.js 10.x, 11.x, 12.x, 13.x, 14.x, 15.x and 16.x.
No support for Node.js < 10.x at the moment in version 3.0.0, use version 2.2.0 for if needed.
Also comes with prebuilt binaries (hosted on Github releases), thanks to Stuart Miller (https://github.com/spmiller).
## Node.js 14.18.x and higher
## Node.js 14.18.x
https://github.com/nodejs/node/pull/33010 landed in Node.js 14.18.0, which makes this module no longer needed for heapdumps on out of memory.
One can use the `--heapsnapshot-near-heap-limit` Node.js CLI option as an native alternative.
One can use the `--heapsnapshot-near-heap-limit` Node.js CLI option as an alternative.
See https://nodejs.org/dist/latest-v14.x/docs/api/cli.html#cli_heapsnapshot_near_heap_limit_max_count.
For Node versions older than 14, use the `2.2.0` release, where this functionality is still present (not maintained anymore).
For Node versions 14 and up, use `--heapsnapshot-near-heap-limit` for out-of-memory heapdumps. This functionality has been removed from `3.0.0`.
# Why?
When running nodejs processes in a low memory environment, every out of memory that occurs is interesting.
To figure out why a process went out of memory, a heap snapshot (e.g. heapdump) can help a lot.
This module creates a heap snapshot right before an out of memory error occurs (by leveraging 'SetOOMErrorHandler' of the V8 engine).
It shows what the heap was filled with right before the out of memory error occured and can be opened with Chrome DevTools (Memory tab).
One can still use the API of this module to create CPU profiles and heapdumps on request
There are several modules around which can create heapdumps (v8-profiler, node-heapdump), but these run in the same process as the one going out of memory. Often, creating heapdump won't work when the node process is already struggling.
This module creates the heap snapshot from a separate process, which solves this issue.
Also, these modules are not able to create a heapdump when an out of memory occurs.
# Why?
There are several modules around which can create heapdumps (v8-profiler, node-heapdump), although this module creates the heap snapshot from a separate process which performs better and doesn't affect the main event loop.
# What?
Based on the work of 'trevnorris' (https://github.com/trevnorris/node-ofe/), this module uses 'isolate.SetOOMErrorHandler' (https://v8docs.nodesource.com/node-8.9/d5/dda/classv8_1_1_isolate.html#a08fd4087f39c33b4ac1c20ad953ce4e3) of the V8 engine, and then creates a heapdump when an actual Out of Memory occurs. To make this happen, a native C++ add-on is used.
Node-gyp is needed to compile this add-on.
# What?
When creating a heapdump of CPU profile on request, the DevTools protocol is used to create these files (no native add-on needed).
When creating a heapdump of CPU profile on request, the DevTools protocol is used to create these files (no native add-on).
The --inspect node.js flag is needed to make this work (which is validated on startup).
# Example
Just run "npm test" to see it in action. It creates a heapdump named "my_heapdump.heapsnapshot" in the 'tests' directory of this module.
# Usage

@@ -55,7 +65,11 @@

# Options
* addTimestamp - add a timestamp to the heapdump filename, to make it unique. Default is false.
* heapdumpOnOOM - boolean whether to create a heapdump when an out of memory occurs. Default true.
* OOMImplementation - Only "NATIVE_HOOK" is supported starting from 3.0.0
"NATIVE_HOOK" relies on the native v8 hook and makes sure that the heapdump is actually created when the OoM occurs. It's more impacted by the OoMKiller of Unix systems though, when being run in memory restricted environments like Docker.
* path - the path where the heapdump ends up when an out of memory error occurs. '.heapsnapshot' is automatically appended. Defaults to this modules' directory.
* addTimestamp - add a timestamp to the out of memory heapdump filename, to make it unique. Default is false.
* port - optionally, the alternative DevTools protocol port. Defaults to 9229. Should map on the port given to the --inspect arg.
# API
The API for creating heapdumps and CPU profiles on request. See below for the currently available API.
Besides creating heapdumps when an out of memory error occurs, there also is an API for creating heapdumps and CPU profiles on request. See below for the currently available API.

@@ -62,0 +76,0 @@ Notice that you cannot create a heapdump while a CPU profile is being generated and vice versa; an Error will be thrown if this is the case.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc