Socket
Socket
Sign inDemoInstall

@clinic/heap-profiler

Package Overview
Dependencies
245
Maintainers
4
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.1.1 to 5.0.0

tags

2

package.json
{
"name": "@clinic/heap-profiler",
"version": "4.1.1",
"version": "5.0.0",
"description": "Programmable interface to Clinic.js Heap Profiler",

@@ -5,0 +5,0 @@ "repository": "https://github.com/clinicjs/node-clinic-heap-profiler",

@@ -22,3 +22,3 @@ # Clinic.js Heap Profiler

- Node.js 14 and above
- Node.js 16 and above

@@ -55,4 +55,6 @@ ## Example

**Default**: false
- dest [`<String>`][] The file where the collected data is stored.
**Default**: `./.clinic/<process.pid>.clinic-heapprofile`
- dest [`<String>`][] Destination for the collected data
**Default**: `.clinic`
- name [`<String>`][] File name for the collected data
**Default**: `<process.pid>.clinic-heapprofiler`

@@ -59,0 +61,0 @@ #### `heapProfiler.collect(args, callback)`

@@ -19,3 +19,3 @@ 'use strict'

function execute (instance, args, env, nodeOptions, cb) {
ensureDir(path.dirname(instance.dest), err => {
ensureDir(instance.path, err => {
/* istanbul ignore if */

@@ -48,3 +48,3 @@ if (err) {

cb(null, instance.dest)
cb(null, `${instance.path}/${instance.name || instance.process.pid}.clinic-heapprofiler`)
})

@@ -110,4 +110,4 @@ })

debug = false,
name,
dest = `.clinic/${name || process.pid}.clinic-heapprofiler`
dest = '.clinic',
name
} = settings

@@ -118,3 +118,4 @@

this.debug = debug
this.dest = dest
this.path = dest
this.name = name
}

@@ -132,3 +133,4 @@

...process.env,
HEAP_PROFILER_DESTINATION: this.dest,
HEAP_PROFILER_NAME: this.name,
HEAP_PROFILER_PATH: this.path,
HEAP_PROFILER_PRELOADER_DISABLED: 'true',

@@ -135,0 +137,0 @@ HEAP_PROFILER_USE_IPC: this.detectPort

@@ -10,3 +10,6 @@ 'use strict'

const clinicPort = parseInt(process.env.CLINIC_HEAP_PROFILER_PORT, 10)
const profilerOptions = { destination: process.env.HEAP_PROFILER_DESTINATION, signal: controller.signal }
const profilerOptions = {
destination: `${process.env.HEAP_PROFILER_PATH}/${process.env.HEAP_PROFILER_NAME || process.pid}.clinic-heapprofiler`,
signal: controller.signal
}

@@ -13,0 +16,0 @@ let toSend = 2 // We need to send two ports: the IPC one and the application one

@@ -8,14 +8,122 @@ 'use strict'

test('cmd - test collect - default name (child_process.pid) and output destination (.clinic)', t => {
const tool = new ClinicHeapProfiler({ debug: true })
function cleanup (err, filepath) {
function callback (err) {
t.error(err)
t.end()
}
t.error(err)
t.match(filepath, /^\.clinic(\/|\\)[0-9]+\.clinic-heapprofiler$/)
fs.rm(path.dirname(filepath), { recursive: true }, callback)
}
tool.collect([process.execPath, path.join('test', 'fixtures', 'randomHashes.js')], (err, filepath) => {
if (err) {
cleanup(err, filepath)
return
}
t.match(filepath, tool.process.pid.toString())
t.ok(fs.statSync(filepath).isFile())
tool.visualize(filepath, `${filepath}.html`, err => {
if (err) {
cleanup(err, filepath)
return
}
t.ok(fs.statSync(`${filepath}.html`).isFile())
cleanup(null, filepath)
})
})
})
test('cmd - test collect - custom output destination', t => {
const tool = new ClinicHeapProfiler({ debug: true, dest: 'test-output-destination' })
function cleanup (err, filename) {
let count = 0
function cleanup (err, filepath) {
function callback (err) {
t.error(err)
t.end()
}
t.error(err)
t.match(filepath, /^test-output-destination/)
fs.rm(path.dirname(filepath), { recursive: true }, callback)
}
tool.collect([process.execPath, path.join('test', 'fixtures', 'randomHashes.js')], (err, filepath) => {
if (err) {
cleanup(err, filepath)
return
}
t.ok(fs.statSync(filepath).isFile())
tool.visualize(filepath, `${filepath}.html`, err => {
if (err) {
cleanup(err, filepath)
return
}
t.ok(fs.statSync(`${filepath}.html`).isFile())
cleanup(null, filepath)
})
})
})
test('cmd - test collect - custom output name', t => {
const tool = new ClinicHeapProfiler({ debug: true, name: 'test-custom-name' })
function cleanup (err, filepath) {
function callback (err) {
t.error(err)
t.end()
}
if (++count === 2) {
t.end()
t.error(err)
t.equal(filepath, '.clinic/test-custom-name.clinic-heapprofiler')
fs.rm(path.dirname(filepath), { recursive: true }, callback)
}
tool.collect([process.execPath, path.join('test', 'fixtures', 'randomHashes.js')], (err, filepath) => {
if (err) {
cleanup(err, filepath)
return
}
t.ok(fs.statSync(filepath).isFile())
tool.visualize(filepath, `${filepath}.html`, err => {
if (err) {
cleanup(err, filepath)
return
}
t.ok(fs.statSync(`${filepath}.html`).isFile())
cleanup(null, filepath)
})
})
})
test('cmd - test collect - custom name and output destination', t => {
const tool = new ClinicHeapProfiler({ debug: true, name: 'test-custom-name', dest: 'test-output-destination' })
function cleanup (err, filepath) {
function callback (err) {
t.error(err)
t.end()
}

@@ -25,27 +133,26 @@

t.match(filename, /^test-output-destination$/)
t.equal(filepath, 'test-output-destination/test-custom-name.clinic-heapprofiler')
fs.unlink(filename, callback)
fs.unlink(filename + '.html', callback)
fs.rm(path.dirname(filepath), { recursive: true }, callback)
}
tool.collect([process.execPath, path.join('test', 'fixtures', 'randomHashes.js')], (err, filename) => {
tool.collect([process.execPath, path.join('test', 'fixtures', 'randomHashes.js')], (err, filepath) => {
if (err) {
cleanup(err, filename)
cleanup(err, filepath)
return
}
t.ok(fs.statSync(filename).isFile())
t.ok(fs.statSync(filepath).isFile())
tool.visualize(filename, `${filename}.html`, err => {
tool.visualize(filepath, `${filepath}.html`, err => {
if (err) {
cleanup(err, filename)
cleanup(err, filepath)
return
}
t.ok(fs.statSync(`${filename}.html`).isFile())
t.ok(fs.statSync(`${filepath}.html`).isFile())
cleanup(null, filename)
cleanup(null, filepath)
})
})
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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