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

Breakpoints sometimes not work #27

Closed
hcnode opened this issue Nov 10, 2020 · 2 comments
Closed

Breakpoints sometimes not work #27

hcnode opened this issue Nov 10, 2020 · 2 comments

Comments

@hcnode
Copy link

hcnode commented Nov 10, 2020

Hi,

I have a problem when I use Effectful Javascript Debugger extension in vscode, hope I did not go to the wrong place.

In the codes below, when a breakpoint set on line 'console.log(line);', assume two lines in input.txt, so the breakpoint line should be stopped twice when debug run, but actually only stopped when first line read.

var fs = require('fs'),
    readline = require('readline');

var rd = readline.createInterface({
    input: fs.createReadStream('path/to/input.txt'),
    output: process.stdout,
});

rd.on('line', function(line) {
    console.log(line);
});

The launch config is created by default:

{
	"type": "effectful",
	"request": "launch",
	"name": "Launch Node application",
	"preset": "node",
	"cwd": "${workspaceRoot}",
	"command": "node",
	"args": [
		"${file}"
	],
	"console": "integratedTerminal",
	"env": {}
}

The version of the Effectful Javascript Debugger extension I installed is v1.3.42

@awto
Copy link
Owner

awto commented Nov 10, 2020

Yes, unfortunately, the debugger doesn't work well when runtime calls some user functions synchronously. The breakpoint releases the main thread so readline thinks the event handling is done and it can proceed with something else.

I'm going to release the next major update in a couple of weeks. It will work a bit better - at least it will stop on the breakpoints. However, it won't stop the readline, so it will proceed to output the lines to process.stdout even when stopped on a breakpoint.

However, even now breakpoints should work when in time-traveling mode. If you enable time-traveling, execute your program till the end, and after go back and forward everything breakpoints should work. With other advantages, like you don't need to restart the process.

There are a couple of solutions for non-time-traveling modes but in longer-term plans. For example, we can transpile embedded node modules (if they are in JS) this way everything will work immediately. Or we can try to block the main thread instead of releasing(#10) it, etc. But I cannot give any estimates for these features. If you wish to contribute anything I'll be happy to help.

@hcnode
Copy link
Author

hcnode commented Nov 11, 2020

Thank you for so detail explain!

I have not used the time-traveling mode yet, it sounds AWESOME! I will try it!

@hcnode hcnode closed this as completed Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants