Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

backtrace-node

Package Overview
Dependencies
Maintainers
4
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backtrace-node - npm Package Compare versions

Comparing version 1.0.0-alpha.4 to 1.0.0-alpha.5

0

lib/backtraceApi.d.ts

@@ -0,0 +0,0 @@ /// <reference types="node" />

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ /// <reference types="node" />

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { BacktraceReport } from './model/backtraceReport';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ /// <reference types="node" />

4

lib/helpers/moduleResolver.js

@@ -31,2 +31,6 @@ "use strict";

}
// solve problem when root module doesn't exists
if (!fs.existsSync(root)) {
return readParentDir(root, depth);
}
var filePath = fs.lstatSync(root).isFile();

@@ -33,0 +37,0 @@ if (filePath) {

@@ -0,1 +1,2 @@

export declare function readMemoryInformation(): object;
export declare function readProcessStatus(): object;

@@ -12,4 +12,69 @@ "use strict";

var process = __importStar(require("process"));
var sys = process.platform;
var memInfoRe = /^(.+):\s+(\d+)\s*(.+)?$/;
var memInfoToAttr = {
MemTotal: 'system.memory.total',
MemFree: 'system.memory.free',
MemAvailable: 'system.memory.available',
Buffers: 'system.memory.buffers',
Cached: 'system.memory.cached',
SwapCached: 'system.memory.swap.cached',
Active: 'system.memory.active',
Inactive: 'system.memory.inactive',
SwapTotal: 'system.memory.swap.total',
SwapFree: 'system.memory.swap.free',
Dirty: 'system.memory.dirty',
Writeback: 'system.memory.writeback',
Slab: 'system.memory.slab',
VmallocTotal: 'system.memory.vmalloc.total',
VmallocUsed: 'system.memory.vmalloc.used',
VmallocChunk: 'system.memory.vmalloc.chunk',
};
function readMemoryInformation() {
if (sys === 'win32') {
return {};
}
var result = {};
var file = '';
try {
file = fs.readFileSync('/proc/meminfo', { encoding: 'utf8' });
}
catch (err) {
return {};
}
var lines = file.split('\n');
for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
var line = lines_1[_i];
if (!line) {
continue;
}
var match = line.match(memInfoRe);
if (!match) {
continue;
}
var name_1 = match[1];
var attrName = memInfoToAttr[name_1];
if (!attrName) {
continue;
}
var number = parseInt(match[2], 10);
var units = match[3];
if (number === 0) {
units = 'B';
}
if (units === 'B' || units === 'bytes') {
number *= 1;
}
else if (units === 'kB') {
number *= 1024;
}
else {
continue;
}
result[attrName] = number;
}
return result;
}
exports.readMemoryInformation = readMemoryInformation;
function readProcessStatus() {
var sys = process.platform;
if (sys === 'win32') {

@@ -16,0 +81,0 @@ return {};

@@ -0,0 +0,0 @@ import { BacktraceClient } from './backtraceClient';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export declare class BacktraceClientOptions {

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { ISourceCode } from './sourceCode';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=backtraceData.js.map

@@ -0,0 +0,0 @@ import { IBacktraceData } from './backtraceData';

@@ -211,3 +211,3 @@ "use strict";

BacktraceReport.prototype.readBuiltInAttributes = function () {
return __assign({}, processHelper_1.readProcessStatus(), this.readAttributes(), this.readErrorAttributes());
return __assign({}, processHelper_1.readMemoryInformation(), processHelper_1.readProcessStatus(), this.readAttributes(), this.readErrorAttributes());
};

@@ -242,2 +242,3 @@ BacktraceReport.prototype.detectReportType = function (err) {

var mem = process.memoryUsage();
var _a = (this._callingModule || {}), name = _a.name, version = _a.version, main = _a.main, description = _a.description, author = _a.author;
var result = {

@@ -252,3 +253,9 @@ 'process.age': Math.floor(process.uptime()),

'gc.heap.used': mem.heapUsed,
application: this._callingModule.name,
'node.env': process.env.NODE_ENV,
'debug.port': process.debugPort,
application: name,
version: version,
main: main,
description: description,
author: author,
guid: node_machine_id_1.machineIdSync(true),

@@ -267,2 +274,3 @@ hostname: os.hostname(),

'Environment Variables': process.env,
'Exec Arguments': process.execArgv,
Dependencies: moduleResolver_1.readModuleDependencies(this._callingModulePath),

@@ -269,0 +277,0 @@ };

@@ -0,0 +0,0 @@ import { BacktraceReport } from './backtraceReport';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { ISourceCode } from './sourceCode';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export interface ISourceCode {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=sourceCode.js.map

2

package.json
{
"name": "backtrace-node",
"version": "1.0.0-alpha.4",
"version": "1.0.0-alpha.5",
"description": "Backtrace error reporting tool",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -22,2 +22,7 @@ import * as fs from 'fs';

}
// solve problem when root module doesn't exists
if (!fs.existsSync(root)) {
return readParentDir(root, depth);
}
const filePath = fs.lstatSync(root).isFile();

@@ -24,0 +29,0 @@ if (filePath) {

import * as fs from 'fs';
import * as process from 'process';
const sys = process.platform;
const memInfoRe = /^(.+):\s+(\d+)\s*(.+)?$/;
const memInfoToAttr: { [index: string]: any } = {
MemTotal: 'system.memory.total',
MemFree: 'system.memory.free',
MemAvailable: 'system.memory.available',
Buffers: 'system.memory.buffers',
Cached: 'system.memory.cached',
SwapCached: 'system.memory.swap.cached',
Active: 'system.memory.active',
Inactive: 'system.memory.inactive',
SwapTotal: 'system.memory.swap.total',
SwapFree: 'system.memory.swap.free',
Dirty: 'system.memory.dirty',
Writeback: 'system.memory.writeback',
Slab: 'system.memory.slab',
VmallocTotal: 'system.memory.vmalloc.total',
VmallocUsed: 'system.memory.vmalloc.used',
VmallocChunk: 'system.memory.vmalloc.chunk',
};
export function readMemoryInformation(): object {
if (sys === 'win32') {
return {};
}
const result: { [index: string]: any } = {};
let file = '';
try {
file = fs.readFileSync('/proc/meminfo', { encoding: 'utf8' });
} catch (err) {
return {};
}
const lines = file.split('\n');
for (const line of lines) {
if (!line) {
continue;
}
const match = line.match(memInfoRe);
if (!match) {
continue;
}
const name = match[1];
const attrName = memInfoToAttr[name];
if (!attrName) {
continue;
}
let number = parseInt(match[2], 10);
let units = match[3];
if (number === 0) {
units = 'B';
}
if (units === 'B' || units === 'bytes') {
number *= 1;
} else if (units === 'kB') {
number *= 1024;
} else {
continue;
}
result[attrName] = number;
}
return result;
}
export function readProcessStatus(): object {
const sys = process.platform;
if (sys === 'win32') {

@@ -7,0 +71,0 @@ return {};

@@ -7,3 +7,3 @@ // tslint:disable-next-line: no-var-requires

import { readModule, readModuleDependencies } from '../helpers/moduleResolver';
import { readProcessStatus } from '../helpers/processHelper';
import { readMemoryInformation, readProcessStatus } from '../helpers/processHelper';
import { IBacktraceData } from './backtraceData';

@@ -178,2 +178,3 @@ import { BacktraceStackTrace } from './backtraceStackTrace';

return {
...readMemoryInformation(),
...readProcessStatus(),

@@ -218,2 +219,3 @@ ...this.readAttributes(),

const mem = process.memoryUsage();
const { name, version, main, description, author } = (this._callingModule || {}) as any;
const result = {

@@ -228,3 +230,9 @@ 'process.age': Math.floor(process.uptime()),

'gc.heap.used': mem.heapUsed,
application: this._callingModule.name,
'node.env': process.env.NODE_ENV,
'debug.port': process.debugPort,
application: name,
version,
main,
description,
author,
guid: machineIdSync(true),

@@ -246,2 +254,3 @@ hostname: os.hostname(),

'Environment Variables': process.env,
'Exec Arguments': process.execArgv,
Dependencies: readModuleDependencies(this._callingModulePath),

@@ -248,0 +257,0 @@ } as any;

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc