Skip to content

v8 debugger source url mismatch with workspaces in windows #10672

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

Closed
lacmuch opened this issue Jan 7, 2017 · 6 comments
Closed

v8 debugger source url mismatch with workspaces in windows #10672

lacmuch opened this issue Jan 7, 2017 · 6 comments
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. inspector Issues and PRs related to the V8 inspector protocol question Issues that look for answers.

Comments

@lacmuch
Copy link

lacmuch commented Jan 7, 2017

I want to use chrome as a node js debugger/"ide". node --inspect works fine but when i want to map files with the local file system in windows for live editing... i got problems with the workspace path mappings / breakpoints, etc. Im using NodeJS v7.4

I made a proxy workaround to remap the source urls and replace the directory separators.

My process runs form a subdirectory... thats why i made this: path.resolve(__dirname+'/../..');

This code connects to the standard 5858 debugger ws port and listens on 5859... so you have to change the link when connecting devtools. Example: chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:5859/11212484-27c8-4a50-98c0-e298d8b9942c

If there is a better solution, pls tell me.

this works fine from a seperate process::

var WebSocket = require('ws');
var WebSocketServer = WebSocket.Server;
var path = require('path');
wss = new WebSocketServer({ port: 5859 });
wss.on('connection', function connection(ws) {
	ws.dbgclient = new WebSocket('ws://localhost:5858' + ws.upgradeReq.url);
	console.log('Debug proxy connection: ' + ws.upgradeReq.url);
	ws.dbgclient.on('message', function(message) {
		//From app
		var msg = JSON.parse(message);;
		if (msg.method=='Debugger.scriptParsed') {
			var abspath=path.resolve(__dirname+'/../..');
			if (msg.params.url.indexOf(abspath)==0) {
				msg.params.url=msg.params.url.substring(abspath.length).replace(/\\/g, '/');
			}
		}
		ws.send(JSON.stringify(msg));
	});
	ws.dbgclient.on('close', function() {
		console.log('Host connection closed');
	});
  ws.on('message', function(message) {		
		//From chrome
		var msg = JSON.parse(message);
		if (msg.method=='Debugger.setBreakpointByUrl') {
			msg.params.url=(path.resolve(__dirname+'/../../')+msg.params.url).replace(/\//g, '\\')
		}
		ws.dbgclient.send(JSON.stringify(msg));
  });
	ws.on('close', function() {
		ws.dbgclient.close();
		console.log('Proxy connection closed')
	})
});
@eugeneo
Copy link
Contributor

eugeneo commented Jan 7, 2017 via email

@mscdex mscdex added question Issues that look for answers. inspector Issues and PRs related to the V8 inspector protocol labels Jan 7, 2017
@lacmuch
Copy link
Author

lacmuch commented Jan 7, 2017

@lacmuch
Copy link
Author

lacmuch commented Feb 4, 2017

I made a faster proxy at #11164

@Trott
Copy link
Member

Trott commented Jul 16, 2017

This issue has been inactive for sufficiently long that it seems like perhaps it should be closed. Feel free to re-open (or leave a comment requesting that it be re-opened) if you disagree. I'm just tidying up and not acting on a super-strong opinion or anything like that.

@Trott Trott closed this as completed Jul 16, 2017
@lacmuch
Copy link
Author

lacmuch commented Oct 26, 2017

The problem still exists.... nodejs in windows use backslash as dirseg... and chrome can't map with local workspace. I override the path with //@ sourceURL=/path/to/file in every file now.

@Trott Trott reopened this Oct 27, 2017
@bnoordhuis
Copy link
Member

I'll close this out as a duplicate of #10838. It's newer than this issue but has more info and discussion.

@bnoordhuis bnoordhuis added the duplicate Issues and PRs that are duplicates of other issues or PRs. label Oct 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. inspector Issues and PRs related to the V8 inspector protocol question Issues that look for answers.
Projects
None yet
Development

No branches or pull requests

5 participants