New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

newrelic

Package Overview
Dependencies
Maintainers
1
Versions
393
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

newrelic - npm Package Compare versions

Comparing version 0.9.11-88 to 0.9.12-91

7

lib/agent.js

@@ -106,2 +106,8 @@ 'use strict';

sampler.stop();
// invalidate the old collector connection
if (this.connection) {
this.connection.sendShutdown();
delete this.connection;
}
};

@@ -112,3 +118,2 @@

this.connection.sendShutdown();
this.stop();

@@ -115,0 +120,0 @@ this.start();

42

lib/collector/connection.js

@@ -11,2 +11,8 @@ 'use strict';

function isRestart(error) {
return error &&
error.error_type &&
error.error_type === 'NewRelic::Agent::ForceRestartException';
}
function CollectorConnection(agent) {

@@ -45,16 +51,6 @@ events.EventEmitter.call(this);

if (typeof error === 'object') {
// we can get a restart at any point
if (error.error_type === 'NewRelic::Agent::ForceRestartException' &&
!this.finished) {
logger.info("New Relic wants the agent to restart.");
this.agent.emit('restart');
this.emit('end');
}
else {
logger.info("An error occurred invoking method %s:", method);
logger.debug(error);
}
logger.info(error, "An error occurred invoking method %s:", method);
}
else {
logger.info("An error occurred invoking method %s: %j", method, error);
logger.info("An error occurred invoking method %s: %s", method, error);
}

@@ -70,2 +66,12 @@ }.bind(this));

var sender = this.createDataSender(methodName, data, responseCallback, errorCallback);
// a restart can come in response to any method invocation
sender.on('error', function restartHandler(method, error) {
if (isRestart(error) && !this.finished) {
logger.debug("New Relic wants the agent to reconnect.");
this.agent.emit('restart');
this.emit('end');
}
}.bind(this));
sender.invokeMethod(remoteName, data);

@@ -127,2 +133,3 @@ };

CollectorConnection.prototype.destroy = function () {
logger.info("Shutting down New Relic connection with run ID %s.", this.agentRunId);
delete this.agentRunId;

@@ -183,5 +190,14 @@ this.finished = true;

CollectorConnection.prototype.sendShutdown = function () {
this.invokeMethod('shutdown', 'shutdown');
var sender = this.createDataSender('shutdown', null, null,
function (method, error) {
if (isRestart(error)) {
logger.info("Connection to New Relic terminated.");
}
else {
logger.warn("Unexpected response on shutdown: %s", error);
}
});
sender.invokeMethod('shutdown');
};
module.exports = CollectorConnection;

@@ -35,4 +35,6 @@ 'use strict';

if (typeof error === 'object') {
logger.debug("Attempting to send data to collector %s failed:", hostname);
logger.debug(error);
if (error.error_type !== 'NewRelic::Agent::ForceRestartException') {
logger.debug("Attempting to send data to collector %s failed:", hostname);
logger.debug(error);
}
}

@@ -39,0 +41,0 @@ else {

@@ -0,1 +1,6 @@

### v0.9.12-91 / beta-12 (2012-12-28):
* Fixed the agent's auto-restart support to cleanly shut down the
connection (also fixed a bunch of bugs in restart).
### v0.9.11-88 / beta-11 (2012-12-20):

@@ -8,3 +13,3 @@

* If you're on a SmartOS VM with a 64-bit base image and a 64-bit build of
node that's v0.8.5 or earlier, the agent will no longer cause node to
Node that's v0.8.5 or earlier, the agent will no longer cause Node to
crash. Don't even ask.

@@ -11,0 +16,0 @@

{
"name": "newrelic",
"version": "0.9.11-88",
"version": "0.9.12-91",
"author": "New Relic Node.js agent team <nodejs@newrelic.com>",

@@ -5,0 +5,0 @@ "contributors": [

@@ -112,3 +112,9 @@ # New Relic Node.js agent

The New Relic Node.js agent is free-to-use, proprietary software. Please see
the full license (found in LICENSE in this distribution) for details.
The New Relic Node.js agent uses code from the following open source projects
under the following licenses:
bunyan http://opensource.org/licenses/MIT
The New Relic Node.js agent itself is free-to-use, proprietary software.
Please see the full license (found in LICENSE in this distribution) for
details.

@@ -35,7 +35,8 @@ 'use strict';

// CONSTANTS
var SAMPLE_RUN_ID = 101010101
, PROTOCOL_VERSION = 9
;
describe("with a mocked DataSender", function () {
var SAMPLE_RUN_ID = 101010101
, PROTOCOL_VERSION = 9
;
var connection

@@ -195,2 +196,37 @@ , mockConnection

});
describe("when sent a ForcedRestartException by the collector", function () {
it("should restart", function (done) {
var invokeMethod = DataSender.prototype.invokeMethod;
agent.once('restart', function () {
// if this event is received, mission accomplished
DataSender.prototype.invokeMethod = invokeMethod;
return done();
});
// don't need to actually talk to the connector
var emitted = false;
DataSender.prototype.invokeMethod = function (name, data) {
// don't keep emitting errors or else sendShutdown will trigger an infinite
// recursion.
if (!emitted) {
emitted = true;
this.emit('error', 'metric_data', {
error_type : "NewRelic::Agent::ForceRestartException",
message : "RPM has detected that this agent has stale configuration. " +
"Launch time=2012-12-07 22:20:37 " +
"Config time=2012-12-07 22:21:55 " +
"Forcing restart."
});
}
};
var connection = new CollectorConnection(agent);
connection.agentRunId = SAMPLE_RUN_ID;
agent.connection = connection;
connection.sendMetricData(0, 1, [1]);
});
});
});
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