Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

test if connected before enabling profiler. closes #24

  • Loading branch information...
commit 9b25788d72290caf56db81f3c17cbcf32090984f 1 parent ba34583
@dannycoates dannycoates authored
Showing with 42 additions and 26 deletions.
  1. +2 −1  lib/debug-server.js
  2. +40 −25 lib/session.js
View
3  lib/debug-server.js
@@ -3,6 +3,7 @@ var Http = require('http'),
path = require('path'),
WebSocket = require('../vendor/ws'),
paperboy = require('../vendor/paperboy'),
+ debugr = require('./debugger'),
Session = require('./session');
var WEBROOT = path.join(__dirname, '../front-end');
@@ -28,7 +29,7 @@ exports.create = function(options, config) {
wsServer.on('connection', function (conn) {
var port = parseInt((/\?port=(\d+)/.exec(conn._req.url) || [null,debugPort])[1], 10),
- session = Session.create(conn, port, config);
+ session = Session.create(conn, debugr, port, config);
conn.on('message', function (data) {
session.handleRequest(data);
View
65 lib/session.js
@@ -1,12 +1,11 @@
var http = require('http'),
events = require('events'),
- path = require('path'),
- debugr = require('./debugger');
+ path = require('path');
///////////////////////////////////////////////////////////
// exports
-exports.create = function (conn, debuggerPort, config) {
+exports.create = function (conn, debugr, debuggerPort, config) {
var debug = null,
//map from sourceID:lineNumber to breakpoint
breakpoints = {},
@@ -155,12 +154,12 @@ exports.create = function (conn, debuggerPort, config) {
function parsedScripts(msg) {
var scripts = msg.body.map(function(s) {
return {
- sourceID: s.id.toString(),
+ sourceID: String(s.id),
url: s.name,
data: s.source,
firstLine: s.lineOffset,
scriptWorldType: 0,
- path: s.name.split('/')
+ path: String(s.name).split('/')
};
});
scripts.sort(function(a, b) {
@@ -182,7 +181,7 @@ exports.create = function (conn, debuggerPort, config) {
var hidden = config.hidden &&
config.hidden.some(function(r) { return r.test(s.url); }),
item = { hidden: hidden, path: s.url };
- s.url = shorten(s.path);
+ if (s.path.length > 1) s.url = shorten(s.path);
item.url = s.url;
sourceIDs[s.sourceID] = item;
delete s.path;
@@ -470,25 +469,41 @@ exports.create = function (conn, debuggerPort, config) {
},
enableProfiler: {
value: function(always) {
- evaluate('process.profiler !== undefined', null, function(msg) {
- if (msg.body.value) {
- sendEvent('profilerWasEnabled');
- }
- else {
- sendEvent('showPanel', { name: 'console' });
- sendEvent('addConsoleMessage', {
- messageObj: {
- source: 3,
- type: 0,
- level: 2,
- line: 0,
- url: '',
- repeatCount: 1,
- message: 'you must require("v8-profiler") before using the profiler'
- }
- });
- }
- });
+ if (debug && debug.connected) {
+ evaluate('process.profiler !== undefined', null, function(msg) {
+ if (msg.body.value) {
+ sendEvent('profilerWasEnabled');
+ }
+ else {
+ sendEvent('showPanel', { name: 'console' });
+ sendEvent('addConsoleMessage', {
+ messageObj: {
+ source: 3,
+ type: 0,
+ level: 2,
+ line: 0,
+ url: '',
+ repeatCount: 1,
+ message: 'you must require("v8-profiler") before using the profiler'
+ }
+ });
+ }
+ });
+ }
+ else {
+ sendEvent('showPanel', { name: 'console' });
+ sendEvent('addConsoleMessage', {
+ messageObj: {
+ source: 3,
+ type: 0,
+ level: 2,
+ line: 0,
+ url: '',
+ repeatCount: 1,
+ message: 'not connected to node'
+ }
+ });
+ }
}
},
disableProfiler: {
Please sign in to comment.
Something went wrong with that request. Please try again.