Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: googleapis/cloud-debug-nodejs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ca07bd84e778805a589e0269c6aaebb76f45aa45
Choose a base ref
...
head repository: googleapis/cloud-debug-nodejs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cf06a70f46aa1a65d888b229289f703340c4dc28
Choose a head ref
  • 10 commits
  • 14 files changed
  • 4 contributors

Commits on Mar 16, 2017

  1. Fix for e2e tests (#252)

    PR-URL: #252
    kjin authored Mar 16, 2017
    Copy the full SHA
    62dd6a8 View commit details

Commits on Mar 24, 2017

  1. Fix breakpoint formatting in logs (#253)

    PR-URL: #253
    kjin authored Mar 24, 2017
    Copy the full SHA
    be0a55c View commit details

Commits on Apr 3, 2017

  1. Copy the full SHA
    68c0c13 View commit details

Commits on May 1, 2017

  1. Copy the full SHA
    4360f88 View commit details

Commits on May 11, 2017

  1. Add yarn.lock (#257)

    PR-URL: #257
    matthewloring authored May 11, 2017
    Copy the full SHA
    022d1ba View commit details

Commits on May 16, 2017

  1. Update deps, drop support for 0.12 (#258)

    This change updates google-cloud/common to a version which is no longer
    compatable with node v0.12. To upgrade this dependency, we must drop
    support for 0.12 as well. Additionally, we prune out some code paths
    that were only executed on node versions less than 1.6.
    
    PR-URL: #258
    matthewloring authored May 16, 2017
    Copy the full SHA
    8a119de View commit details
  2. Avoid retries in e2e tests (#260)

    The new retry-request behavior was causing timeouts on the e2e tests. We
    avoid this by using request instead.
    
    PR-URL: #260
    matthewloring authored May 16, 2017
    Copy the full SHA
    5f45dbf View commit details
  3. Copy the full SHA
    0045ad5 View commit details
  4. 2.0.0 Release Proposal (#259)

    PR-URL: #259
    matthewloring authored May 16, 2017
    Copy the full SHA
    32b0e57 View commit details
  5. 2.0.0

    Matt Loring committed May 16, 2017
    Copy the full SHA
    cf06a70 View commit details
Showing with 1,713 additions and 291 deletions.
  1. +3 −1 .travis.yml
  2. +18 −0 CHANGELOG.md
  3. +1 −1 README.md
  4. +8 −7 package.json
  5. +4 −4 src/agent/debuglet.js
  6. +5 −98 src/agent/state.js
  7. +7 −1 test/fixtures/fib.js
  8. +5 −12 test/test-debuglet.js
  9. +18 −55 test/test-duplicate-nested-expressions.js
  10. +0 −8 test/test-fat-arrow.js
  11. +7 −27 test/test-this-context.js
  12. +11 −28 test/test-try-catch.js
  13. +14 −49 test/test-v8debugapi.js
  14. +1,612 −0 yarn.lock
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
language: node_js
dist: trusty
node_js:
- '0.12'
- '4'
- '6'
- '7'
script:
- ./bin/run-test.sh -c
notifications:
email:
- nodejs-build-notifications+travis@googlegroups.com
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Node.js Agent for Google Cloud Debug ChangeLog

# 2017-05-15, Version 2.0.0 (Experimental), @matthewloring

### Notable changes

This release drops support for versions of Node.js <4.

**Semver Major**

* [[`8a119de64f`](https://github.com/GoogleCloudPlatform/cloud-debug-nodejs/commit/8a119de64f)] - Update deps, drop support for 0.12 (#258) (Matthew Loring) [#258](https://github.com/GoogleCloudPlatform/cloud-debug-nodejs/pull/258)

### Commits

* [[`0045ad5702`](https://github.com/GoogleCloudPlatform/cloud-debug-nodejs/commit/0045ad5702)] - Add test notifications to travis (#261) (Matthew Loring) [#261](https://github.com/GoogleCloudPlatform/cloud-debug-nodejs/pull/261)
* [[`5f45dbf2c6`](https://github.com/GoogleCloudPlatform/cloud-debug-nodejs/commit/5f45dbf2c6)] - Avoid retries in e2e tests (#260) (Matthew Loring) [#260](https://github.com/GoogleCloudPlatform/cloud-debug-nodejs/pull/260)
* [[`8a119de64f`](https://github.com/GoogleCloudPlatform/cloud-debug-nodejs/commit/8a119de64f)] - Update deps, drop support for 0.12 (#258) (Matthew Loring) [#258](https://github.com/GoogleCloudPlatform/cloud-debug-nodejs/pull/258)
* [[`022d1ba5cb`](https://github.com/GoogleCloudPlatform/cloud-debug-nodejs/commit/022d1ba5cb)] - Add yarn.lock (#257) (Matthew Loring) [#257](https://github.com/GoogleCloudPlatform/cloud-debug-nodejs/pull/257)
* [[`4360f88e6a`](https://github.com/GoogleCloudPlatform/cloud-debug-nodejs/commit/4360f88e6a)] - drop dependency on dummy counter module (#256) (Ali Ijaz Sheikh)

## 2017-03-14, Version 1.0.0 (Experimental), @dominicdkramer

### Semver-major changes
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ This module provides Stackdriver Debugger support for Node.js applications. [Sta
[![Cloud Debugger Intro](http://img.youtube.com/vi/tyHcK_kAOpw/0.jpg)](https://www.youtube.com/watch?v=tyHcK_kAOpw)

## Prerequisites
* Stackdriver Debugger is comptible with Node.js version 0.12 or greater. Node.js v5+ is recommended.
* Stackdriver Debugger is comptible with Node.js version 4 or greater. Node.js v5+ is recommended.

## Quick Start
```shell
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@google-cloud/debug-agent",
"version": "1.0.0",
"version": "2.0.0",
"author": "Google Inc.",
"description": "Stackdriver Debug Agent for Node.js",
"main": "./src/index.js",
@@ -18,7 +18,7 @@
],
"license": "Apache-2.0",
"engines": {
"node": ">=0.12"
"node": ">=4"
},
"devDependencies": {
"changelog-maker": "^2.2.2",
@@ -28,17 +28,18 @@
"istanbul": "^0.4.1",
"jshint": "^2.7.0",
"mocha": "^3.0.0",
"nock": "^9.0.0"
"nock": "^9.0.0",
"proxyquire": "^1.7.11",
"request": "^2.81.0"
},
"dependencies": {
"@google-cloud/common": "^0.12.0",
"acorn": "^4.0.3",
"@google-cloud/common": "^0.13.3",
"acorn": "^5.0.3",
"async": "^2.1.2",
"coffee-script": "^1.9.3",
"findit2": "^2.2.3",
"gcp-metadata": "^0.1.0",
"gcp-metadata": "^0.2.0",
"lodash": "^4.12.0",
"request": "^2.61.0",
"semver": "^5.1.0",
"source-map": "^0.5.1",
"split": "^1.0.0"
8 changes: 4 additions & 4 deletions src/agent/debuglet.js
Original file line number Diff line number Diff line change
@@ -78,7 +78,7 @@ var formatBreakpoint = function(msg, breakpoint) {
*/
var formatBreakpoints = function(msg, breakpoints) {
return msg + Object.keys(breakpoints).map(function (b) {
formatBreakpoint('', b);
return formatBreakpoint('', breakpoints[b]);
}).join('\n');
};

@@ -215,7 +215,7 @@ Debuglet.prototype.start = function() {
// This is ignorable.
}

if (semver.satisfies(process.version, '5.2 || <0.12')) {
if (semver.satisfies(process.version, '5.2 || <4')) {
// Using an unsupported version. We report an error message about the
// Node.js version, but we keep on running. The idea is that the user
// may miss the error message on the console. This way we can report the
@@ -455,7 +455,7 @@ Debuglet.prototype.scheduleBreakpointFetch_ = function(seconds) {
});
that.updateActiveBreakpoints_(bps);
if (Object.keys(that.activeBreakpointMap_).length) {
that.logger_.info(formatBreakpoint('Active Breakpoints: ',
that.logger_.info(formatBreakpoints('Active Breakpoints: ',
that.activeBreakpointMap_));
}
that.scheduleBreakpointFetch_(that.config_.breakpointUpdateIntervalSec);
@@ -550,7 +550,7 @@ Debuglet.prototype.addBreakpoint_ = function(breakpoint, cb) {
return;
}

if (semver.satisfies(process.version, '5.2 || <0.12')) {
if (semver.satisfies(process.version, '5.2 || <4')) {
var message = NODE_VERSION_MESSAGE;
that.logger_.error(message);
breakpoint.status = new StatusMessage(StatusMessage.UNSPECIFIED,
103 changes: 5 additions & 98 deletions src/agent/state.js
Original file line number Diff line number Diff line change
@@ -23,12 +23,9 @@ module.exports = {

var ScopeType = require('vm').runInDebugContext('ScopeType');
var assert = require('assert');
var semver = require('semver');
var util = require('util');
var lodash = require('lodash');
var find = lodash.find;
var transform = lodash.transform;
var remove = lodash.remove;
var flatten = lodash.flatten;
var isEmpty = lodash.isEmpty;

@@ -302,23 +299,13 @@ StateResolver.prototype.resolveFrame_ = function(frame, underFrameCap) {
varTableIndex: ARG_LOCAL_LIMIT_MESSAGE_INDEX
});
} else {
args = this.extractArgumentsList_(frame);
// We will use the values aggregated from the ScopeMirror traversal stored
// in locals which will include any applicable arguments from the invocation.
args = [];
locals = this.resolveLocalsList_(frame, args);
if (isEmpty(locals)) {
locals = [];
}
if (semver.satisfies(process.version, '<1.6')) {
// If the node version is over 1.6 we do not read the frame arguments since
// the values produced by the frame for the arguments may contain inaccurate
// values. If the version is lower than 1.6, though, the frame's argument
// list can be relied upon to produce accurate values for arguments.
args = !isEmpty(args) ? this.resolveArgumentList_(args) : [];
} else {
// Otherwise, if the version is 1.6 or higher than we will use the values
// aggregated from the ScopeMirror traversal stored in locals which will
// include any applicable arguments from the invocation.
args = [];
}
}
return {
function: this.resolveFunctionName_(frame.func()),
@@ -355,13 +342,6 @@ StateResolver.prototype.extractArgumentsList_ = function (frame) {
return args;
};

StateResolver.prototype.resolveArgumentList_ = function(args) {
var resolveVariable = this.resolveVariable_.bind(this);
return args.map(function (arg){
return resolveVariable(arg.name, arg.value);
});
};

/**
* Iterates and returns variable information for all scopes (excluding global)
* in a given frame. FrameMirrors should return their scope object list with
@@ -396,34 +376,7 @@ StateResolver.prototype.resolveLocalsList_ = function (frame, args) {
scope.details().object(),
function (locals, value, name) {
var trg = makeMirror(value);
var argMatch = find(args, {name: name});
if (argMatch && (semver.satisfies(process.version, '<1.6'))) {
// If the version is lower than 1.6 we will use the frame's argument
// list to source argument values, yet the ScopeMirror traversal for
// these Node versions will also return the arguments. Therefore, on
// these versions, compare the value sourced as the argument from
// the FrameMirror to the argument found in the ScopeMirror locals
// list with the same name and attempt to determine whether or not
// they have the same value. If each of these items has the same
// name and value we may assume that the ScopeMirror variable
// representation is merely a duplicate of the FrameMirror's
// variable representation. Otherwise, the variable may have been
// redeclared or reassigned in the function and is therefore a local
// triggering removal from the arguments list and insertion into the
// locals list.
if (argMatch.value.value() === trg.value()) {
// Argument ref is the same ref as the local ref - this is an
// argument do not push this into the locals list
return locals;
}
// There is another local/scope var with the same name and it is not
// the argument so this will take precedence. Remove the same-named
// entry from the arguments list and push the local value onto the
// locals list.
remove(args, {name: name});
usedNames[name] = true;
locals.push(self.resolveVariable_(name, trg));
} else if (!usedNames[name]) {
if (!usedNames[name]) {
// It's a valid variable that belongs in the locals list and wasn't
// discovered at a lower-scope
usedNames[name] = true;
@@ -507,55 +460,9 @@ StateResolver.prototype.storeObjectToVariableTable_ = function(obj) {

/**
* Responsible for recursively resolving the properties on a
* provided object mirror. Due to a bug in early node versions,
* we maintain two implementations using the fast approach
* for supported node versions.
*
* See https://github.com/iojs/io.js/issues/1190.
* provided object mirror.
*/
StateResolver.prototype.resolveMirror_ = function(mirror) {
if (semver.satisfies(process.version, '<1.6')) {
return this.resolveMirrorSlow_(mirror);
} else {
return this.resolveMirrorFast_(mirror);
}
};

// A slower implementation of resolveMirror_ which is safe for all node versions
StateResolver.prototype.resolveMirrorSlow_ = function(mirror) {
// Instead, let's use Object.keys. This will only get the enumerable
// properties. The other alternative would be Object.getOwnPropertyNames, but
// I'm going with the former as that's what util.inspect does.
var that = this;

var keys = Object.keys(mirror.value());
var maxProps = that.config_.capture.maxProperties;
var truncate = maxProps && keys.length > maxProps;
if (truncate) {
keys = keys.slice(0, maxProps);
}
var members = keys.map(function(prop) {
return that.resolveMirrorProperty_(mirror.property(prop));
});
if (truncate) {
members.push({name: 'Only first `config.capture.maxProperties=' +
this.config_.capture.maxProperties +
'` properties were captured'});
}

var mirrorVal = mirror.value();
var len = mirrorVal && mirrorVal.length;
return {
value: mirror.toText() +
((typeof len === 'undefined') ? '' : ' of length ' + len),
members: members
};
};

// A faster implementation of resolveMirror_ which segfaults in node <1.6
//
// See https://github.com/iojs/io.js/issues/1190.
StateResolver.prototype.resolveMirrorFast_ = function(mirror) {
var properties = mirror.properties();
var maxProps = this.config_.capture.maxProperties;
var truncate = maxProps && properties.length > maxProps;
8 changes: 7 additions & 1 deletion test/fixtures/fib.js
Original file line number Diff line number Diff line change
@@ -21,13 +21,19 @@ function fib(n) {
* limitations under the License.
*/

var proxyquire = require('proxyquire');
proxyquire('gcp-metadata', {
'retry-request': require('request')
});

var debuglet = require('../..').start({
debug: {
logLevel: 2,
maxLogsPerSecond: 2,
logDelaySeconds: 5,
breakpointUpdateIntervalSec: 1,
testMode_: true
testMode_: true,
allowExpressions: true
}
});

17 changes: 5 additions & 12 deletions test/test-debuglet.js
Original file line number Diff line number Diff line change
@@ -15,6 +15,11 @@
*/
'use strict';

var proxyquire = require('proxyquire');
proxyquire('gcp-metadata', {
'retry-request': require('request')
});

var _ = require('lodash');
var assert = require('assert');
var DEFAULT_CONFIG = require('../src/agent/config.js');
@@ -78,15 +83,9 @@ describe('Debuglet', function() {
var debug = require('../src/debug.js')();
var debuglet = new Debuglet(debug, defaultConfig);

// The following mock is neccessary for the case when the test is running
// on GCP. In that case we will get the projectId from the metadata
// service.
var scope = nocks.projectId(404);

debuglet.once('initError', function(err) {
assert.ok(err);
// no need to stop the debuggee.
scope.done();
done();
});
debuglet.once('started', function() { assert.fail(); });
@@ -98,14 +97,8 @@ describe('Debuglet', function() {
var debug = require('../src/debug.js')();
var debuglet = new Debuglet(debug, defaultConfig);

// The following mock is neccessary for the case when the test is running
// on GCP. In that case we will get the projectId from the metadata
// service.
var scope = nocks.projectId(404);

debuglet.once('started', function() { assert.fail(); });
debuglet.once('initError', function() {
scope.done();
done();
});
debuglet.start();
Loading