Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Breakpoints never hit for typescript #255

Closed
Alphapage opened this issue Nov 14, 2017 · 8 comments
Closed

Breakpoints never hit for typescript #255

Alphapage opened this issue Nov 14, 2017 · 8 comments
Assignees

Comments

@Alphapage
Copy link

Hello,

Here is the steps to reproduce:

  • entry.js
console.log('hello world from entry');

class C{}


require('./Helloworld');
  • Helloworld.ts



class Startup {
    public static main(): number {
        console.log('Hello World');
        return 0;
    }
}

new Startup(); // put breakpoint here



Startup.main(); // put breakpoint here

The breakpoints are never hit because sourcemap file is processing too late.

I use es6 in tsconfig and I don't add outFiles to launch config.

@roblourens
Copy link
Member

I assume this is node?

and I don't add outFiles to launch config.

Well, there's your problem :) It is required for this scenario.

@Alphapage
Copy link
Author

You are right : this is node.
But I think outFiles is a bad hack: it resolves sourcemaps before starting chrome debugger, so the breakpoints are mapped in that case.
Wouldn't it be better to get all breakpoints paths from vscode ide, resolve them at entrypoint debug-brk then we have the sourcemaps ready. Previous scenario will work as expected too.

@roblourens
Copy link
Member

But we can't resolve from source -> generated script without knowing where the generated script is in the first place.

@Alphapage
Copy link
Author

You are right. So, the only way would be to pause on every script entry in onScriptParsed maybe, resolve sourcemaps, then resume when ready.
This could solve the eval problem #221 . I don't know how ChromeDevTools is doing: need to investigate the execution order.

@roblourens
Copy link
Member

We are implementing something like this in #241 for chrome-debug, but I think outFiles is much simpler with no runtime perf hit.

@Alphapage
Copy link
Author

In debug mode, I don't really care about runtime perf, so I need your expertise because I need it to work for node (DOMDebugger breakonload is only for browser I think).
You could add a property in launch.json to enable the feature or not if you care about perf.
My problem is that I can stop at the entry of the HelloWorld.ts file like this:

  • ChromeDebugAdapter.ts: onScriptParsed (at the beginning)
if (typeof this._columnBreakpointsEnabled === 'undefined') {
            this.detectColumnBreakpointSupport(script.scriptId).then(() => {
                this.sendInitializedEvent();
            });
        }
// my stop on entry breakpoint
try{
// hack to only get necessary files not nodejs ones
            if (script.url.endsWith('world.js') || script.url.endsWith('ntry.js')) {
                let result = await this.chrome.Debugger.setBreakpointByUrl({ urlRegex:".*js", lineNumber: 0, columnNumber: 0 });
                // let result2 = await this.chrome.Debugger.pause()
                this.breakpointEvalId=result.breakpointId
            }


        }
        catch(err) {
            logger.log(err)
        }
        // let result2 = await this.chrome.Debugger.resume()

I can manually resume in vscode ide, but I can't find a way to resume from vscode-chrome-debug-core programmatically.
I often get a websocket error!

Thank you in advance to help me a little more.

@roblourens
Copy link
Member

That's not guaranteed to work, because the script is still running at the same time that code is trying to set a breakpoint. The PR I linked implements two strategies, one using the DOMDebugger api, another that optimistically sets breakpoints by guessing likely file names.

But... just set outFiles...

@Alphapage
Copy link
Author

My goal is always the same : to get inline sourcemaps from eval in script code.
The outFiles works in this case. I'm OK.

That's not guaranteed to work, because the script is still running at the same time that code is trying to set a breakpoint.

In my previous post, the breakpoint is set at the beginning of Helloworld.ts which is the next script to run: only entry.js is running at that time. So, if I can resume using the ide toolbar, why not programmatically. Is there an onPaused event from vscode ide somewhere to be able to call resume programmatically ? I think it just need to wait until all the core workflow is done to resume.

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

No branches or pull requests

2 participants