firefox-devtools / debugger

The faster and smarter Debugger for Firefox DevTools 🔥🦊🛠
https://firefox-dev.tools/
4.61k stars 759 forks source link

Setting breakpoint in JSX adds another breakpoint on the line above #6685

Closed gerdneuman closed 5 years ago

gerdneuman commented 6 years ago

I use current Nightly version on Windows 10

Steps to Reproduce:

  1. Go to vanilla React App: https://new.codesandbox.io/
  2. Set a breakpoint on line 9 of index.js: image
  3. Reload

What happens: Now there is also a breakpoint on line 8 which I never set: image

Expected: This breakpoint on line 8 should not be added.

Maybe related: Why are there 2 index.js files on the left Sources panel? See above screenshot. Or is this another bug?

darkwing commented 6 years ago

There are two index.js files because the sourcemapped URL is the same as the ugly file. We have an enhancement for that coming with https://github.com/devtools-html/debugger.html/pull/6548

janodvarko commented 6 years ago

I am seeing different behavior on my machine:

My STR: 1) Go to vanilla React App: https://new.codesandbox.io/ 2) Set a breakpoint on line 9 of index.ts (I don't see index.js) 3) Reload the page 4) The debugger breaks in process.ts, line 38

Note that both index.ts and process.ts are source mapped from browserfs.min.js Bug in source mapping?

Honza

jasonLaster commented 6 years ago

It looks like we:

  1. pause in the generated location 19 (we should pause at line 9 in the original file)
  2. the breakpoint shifted down to line 17... not sure why
screen shot 2018-09-17 at 1 47 09 pm screen shot 2018-09-17 at 1 47 16 pm
loganfsmyth commented 5 years ago

It looks like the example site has changed since this was filed, so it doesn't reproduce anymore. The generated code is formatted differently.

gerdneuman commented 5 years ago

@loganfsmyth Source code slightly changed, but are mainly the same:

image

But the AR are different now but still not what I would expect:

Debugger does not stop at line 8 of mapped source file now, but stops on the unmapped index.js file:

image

My ER would be to have the Debugger stop at the mapped index.js where I set the breakpoint.

loganfsmyth commented 5 years ago

Alright perfect.

The issue here appears to be caused by the fact that the url of the mapped file is the same as the URL of the generated file, which means that when the page reloads and hits https://github.com/devtools-html/debugger.html/blob/9309042df4ecd99c8859b190d8fc8287e18851ad/src/actions/sources/newSources.js#L113, the generated file loads first and causes the selection to change to the generated file before the original file has loaded.

I'm thinking that this check should be using sourceId instead of url, but I'd have to dig in more to see if there are issues with changing to that approach.(This won't work)

janodvarko commented 5 years ago

Is this fixed? I can't reproduce the new case described here: https://github.com/devtools-html/debugger.html/issues/6685#issuecomment-432301947

For me the page breaks correctly in (mapped) file.

Honza

jasonLaster commented 5 years ago

It works well for me too