Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script is resumed as soon as node-inspector is loaded #534

Closed
ELLIOTTCABLE opened this issue Jan 23, 2015 · 68 comments
Closed

Script is resumed as soon as node-inspector is loaded #534

ELLIOTTCABLE opened this issue Jan 23, 2015 · 68 comments
Assignees
Labels
Milestone

Comments

@ELLIOTTCABLE
Copy link
Contributor

I'm launching my program with --debug-brk. Execution is immediately paused. However, as soon as I load up node-inspector's page in Chrome, the script resumes, and immediately crashes (with the error I'm trying to debug). This gives me no time to set, say, a breakpoint. (Incidentally, debugger; statements don't help.)


Affects node v0.11.14 and higher. Use an earlier version of node to unblock yourself

Node v0.10.38 will give you the profiler 'partial support' warning which you can ignore if you do not use the profiler. Use v0.11.13 as the warning suggests if you need the profiler.


I'm not sure what other information I can share, here. My own code is fairly complex; if you'd like to try and reproduce this on your end, the following should approximately duplicate the environment where I'm seeing this:

brew install nvm
nvm install 0.11
nvm use 0.11
npm install -g node-inspector
node-inspector &
git clone git@github.com:Paws/Rulebook.git --branch letter-01
git clone git@github.com:ELLIOTTCABLE/Paws.js.git --branch support-rulebook
cd Paws.js
npm install
npm install # yes, run it twice. bugs in my codebase. unrelated.
node --debug-brk ./Executables/paws.js check "../Rulebook/The Letters/01. On rules, meaning, and consistency.rules.yaml"
# At this point, it should be paused ...
# ... but as soon as you load up http://127.0.0.1:8080/debug?port=5858, for me, it resumes and crashes.
@3y3
Copy link
Member

3y3 commented Jan 23, 2015

Please share also error message.

@3y3
Copy link
Member

3y3 commented Jan 23, 2015

Can you reproduce this behavior on some siple app? (for example node-debug-samples)

@ELLIOTTCABLE
Copy link
Contributor Author

@3y3 from what? There's no error, it just opens, flashes the inspector for a moment, and then my code resumes-fails-exits, returning the inspector to the “Hit Cmd+O to open a file” view.

@ELLIOTTCABLE
Copy link
Contributor Author

re: simpler codebase, I'll try that right now. (Wasn't expecting this quick of a reply at 4AM Chicago time, heh; about to crash soon. FYI.)

@ELLIOTTCABLE
Copy link
Contributor Author

Works fine on node-debug-samples/sourcemap. I don't think it's a general problem with NI, I suspect it's the peculiarities of my codebase surfacing some weird edge-case. Problem is, I haven't the slightest idea where to start looking, because I don't … actually know how node-inspector works. >,>

@3y3
Copy link
Member

3y3 commented Jan 23, 2015

Wasn't expecting this quick of a reply at 4AM Chicago time

I work by Russia's Moscow time =)

Works fine on node-debug-samples/sourcemap

That's nice! Now we need to find that is special in your app. Some cases for test:

  1. Run node-inspector without & this way we can confirm, that ni don't throw errors by himself (looking at his console log)
  2. Run node-inspector with --no-inject flag, this prevents ni from modify your app code (now we wrap all console functions to trace them to frontend)
  3. Try to reproduce this behavior on v0.7.4

@oliverzy
Copy link

I also have this problem but only with Node.js 0.11.15.
0.11.14 doesn't work, 0.11.13 is good

@iliakan
Copy link

iliakan commented Jan 25, 2015

I confirm the problem with 0.11.15 & node-inspector. 0.8.3.

@3y3
Copy link
Member

3y3 commented Jan 25, 2015

Thanks for targetting node version. I can confirm the probem with 0.11.15.

To @bajtos :
The current problem - now we receive debug event when app started with --debug-brk flag, previously we only check that the application is paused. But the initial problem - we can receive a debug event before all sources have been downloaded, in this situation BreakEventHandler._onBreak works incorrectly.

I see two ways to fix this problem:

  1. Cache all incoming events from app, before all sources will loaded in ScriptManager. We already do same thing with all incoming from frontend. In this way I prefer to emit resource-tree event not from PageAgent but from process.
  2. Make BreakEventHandler._onBreak async and try to request source from app on the fly (with caching the response)

Are you see the third?

@iliakan
Copy link

iliakan commented Jan 25, 2015

Both ways look sane. Which one is easier to implement?

@3y3 3y3 added this to the v0.8.4 milestone Jan 26, 2015
@3y3 3y3 added the BUG label Jan 26, 2015
@bajtos
Copy link
Member

bajtos commented Jan 27, 2015

Option 1) looks reasonable to me. It will probably fix also #314 which has been around for quite some time.

@bajtos
Copy link
Member

bajtos commented Jan 27, 2015

Option 1) looks reasonable to me. It will probably fix also #314 which has been around for quite some time.

On the second look, the fix of this issue will most likely not fix #314. However, we should take #314 into consideration while working on the patch, so that we don't make the situation even worse.

@3y3
Copy link
Member

3y3 commented Jan 27, 2015

Ok. We selected first way.

@ELLIOTTCABLE , @oliverzy , @iliakan , are you want to fix this or this is job for me?

@3y3 3y3 added the Easy Pick label Jan 27, 2015
@bajtos
Copy link
Member

bajtos commented Jan 27, 2015

I don't think it is that easy, I'll try to get some time to work on this myself. Unfortunately that won't be sooner than in 2-3 weeks. So if there is anybody else willing to take up the challenge, then go for it!

@iliakan
Copy link

iliakan commented Jan 27, 2015

Please don't treat that as a lack of support, I'm a really a user, not a developer here. Other projects eat 146% of my time.

@iliakan
Copy link

iliakan commented Jan 27, 2015

P.S. Thank you for what you're doing.

@mightyiam
Copy link

👍

@jonathanrdelgado
Copy link

+1, just updated to node 0.12.0 and this issue came up.

@jaslo
Copy link

jaslo commented Feb 17, 2015

Thanks I reported #558, and I'm glad to know someone's looking at it. At some point, I may have time to help, but not now unfortunately.

@ChrisRus
Copy link

I'm going back to 11.3 node until this sorts out. I'm dead in the water w/0.12.0 and latest node-inspector that I can't get to install due to v8-profiler issues on Debian (wheezy).

@bajtos
Copy link
Member

bajtos commented Feb 19, 2015

@ChrisRus Try npm install -g node-inspector@0.7. That version has less native dependencies at the cost of missing profiler tabs.

@fiznool
Copy link

fiznool commented Feb 25, 2015

I'm in the same boat, using node 0.12 and node-inspector 0.9.1. I can confirm this issue exists with node-inspector 0.7.4 as well.

In case you need any further examples, I've reproduced with a very simple script. Screencast here.

@colingoldberg
Copy link

I am having the same issue, with node 0.12.0, node-inspector 0.9.1. Typically I use node-debug for convenience, but the same thing happens running node-inspector plus the --debug-brk option.

I have been experiencing this issue with a fairly complex script. In light of the suggestions above, I have just tried it with a simple script I used to test the mathjs published module. It does not break at the first line, and runs through to completion without any ability to set a breakpoint.

ie.
node-debug test_mathjs.js

The test_mathjs.js script is below:

var math = require('/path/to/node_modules/mathjs');

var parser = math.parser();

var minutes = 1000 * 60;
var hours = minutes * 60;
var days = hours * 24;
var years = days * 365;

var str = 'now()-startTime';
var match = str.match(/[+-]/gi);
console.log(match);
if (match.length > 0) {
var strArray = str.split(match[0]);
console.log(strArray);
if (strArray[0] == 'now()') {
var expr_term1 = Date.now();
}
else {
var expr_term1 = 1111111111111111;
}
if (strArray[1] == 'now()') {
var expr_term2 = Date.now();
}
else {
var expr_term2 = Date.parse('2015-01-28T19:18:48Z');
}

var scope = {
    expr_term1: expr_term1,
    expr_term2: expr_term2
};
var math_expr_str = 'expr_term1 ' + match[0] + ' expr_term2';
var x = math.eval(math_expr_str, scope);
var y = Math.round(x / days);
//var x = parser.get('x');
console.log(y);

}

parser.eval('x = 7 / 2');
var x = parser.get('x');
console.log(x);

var d= Date.parse('2015-01-28T19:18:48Z');

var y = Math.round(d / years);
console.log(y);

var n = Date.now();
var diff = n - d;
console.log(diff);
var y = Math.round(diff / days);
console.log(y);

Colin G

@3y3
Copy link
Member

3y3 commented Apr 24, 2015

Fixed in 0.10.0 release. Reopen this bug if the problem still persists for you.

@3y3 3y3 closed this as completed Apr 24, 2015
@iliakan
Copy link

iliakan commented Apr 24, 2015

Wow! holy dude, I'll start using node-inspector once again!
It even installed on my io.js!

@mightyiam
Copy link

😂

@jaslo
Copy link

jaslo commented Apr 25, 2015

Thank you! Will give it a try tomorrow!

@DaHoopster
Copy link

Still experiencing the issue with node v0.12.2 and node-inspector 0.10.0. Placed breakpoint in the Express 4 app and it wasn't hit. The code just runs to completion.

@aparajita
Copy link

In my case it stopped at the first line as --debug-brk should do, but then did not stop at any breakpoints.

@3y3 3y3 reopened this May 6, 2015
@3y3 3y3 modified the milestones: 0.10.1, v0.10.0 May 6, 2015
@williscool
Copy link

Seems to work for me now.

I use it in cases when I'm running unit tests with mocha --debug and somehow it decides to skip past a breakpoint.

if I run mocha --debug-brk I'm now consistently getting stops using debugger; lines in my code.

using node v0.12.2 and node-inspector 0.10.0 with nvm 0.13.1

I will say the most consistent cases skips over debugger lines happen when running with mocha --debug is in a class like object instantiation with the new keyword.

Maybe it has something to do with jit / hotloading type of code if that helps at all.

Summary: works for me now thanks. hopefully those cases where --debug break for me helps you track stuff down

@3y3
Copy link
Member

3y3 commented May 13, 2015

Fixed in 0.10.1

@3y3 3y3 closed this as completed May 13, 2015
@mightyiam
Copy link

Thank you!

@SujitKumbhar
Copy link

I am facing same problem ..i installed Ni vesion is 0.10.1
i tried with --debug-brk also

auchenberg pushed a commit to auchenberg/node-inspector that referenced this issue Jun 27, 2015
@imamtauhid
Copy link

--debug-brk not running my code, node version 0.12.2 and ni 0.11.1 here. but working with --debug

@Alex-Nabu
Copy link

windows 10 not working. It says listening but whenever I try to visit : http://127.0.0.1:8080/debug?port=5858. says connection refused.

@dpwolfe
Copy link

dpwolfe commented Aug 25, 2015

@Alex-Nabu When you say Windows 10, I'm assuming you are using the new IE Edge browser. Is that correct? If so, have you tried IE (not Edge) in Windows 10 or any other browsers and had different results?

@Alex-Nabu
Copy link

@dpwolfe No I meant chome. I actually have to downgrade my nodejs version to get it working again. downgraded to 0.12.4

@sanfords
Copy link

sanfords commented Sep 7, 2015

--debug-brk isn't working for me at all on Mac OS X 10.10.5 + Node.js 0.12.7 (64-bit) + Chrome 45.0.2454.85 (64-bit). My startup.js script is very simple:

debugger;

var connect = require('connect');
var http    = require('http');

var app = connect();
app.use(function(req, res) {
  console.log(req.url);
  res.end('Hello from Connect!\n');
})

http.createServer(app).listen(3000);
console.log("For status, connect your web browser to http://localhost:3000");

This lands me in the weeds in module.js. Hitting run doesn't stop at debugger.

I'm running with node --debug-brk startup.js. startup.js is definitely loaded in the debugger. It doesn't stop if I put a manual breakpoint there either.

@AlexYegupov
Copy link

node --debug-brk doesn't work (nothing is shown in node-inspector)

% node-inspector --web-port=9000 # 130 17:26 ~/dev/react-starter/node_modules/bootstrap
Node Inspector v0.12.3
Visit http://127.0.0.1:9000/?ws=127.0.0.1:9000&port=5858 to start debugging.

% node --debug-brk ./test.js # 130 17:26 ~/dev/react-starter
Debugger listening on port 5858

test.js:
console.log(1)
console.log(2)

node v0.12.2
Node Inspector v0.12.3
Description: Ubuntu 14.04.3 LTS Release: 14.04
chrome: 45.0.2454.85 (64-bit)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests