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

Malformed "url" parameter in "Debugger.scriptParsed" event #10838

Closed
segrey opened this issue Jan 16, 2017 · 17 comments
Closed

Malformed "url" parameter in "Debugger.scriptParsed" event #10838

segrey opened this issue Jan 16, 2017 · 17 comments
Labels
help wanted Issues that need assistance from volunteers or PRs that need help to proceed. inspector Issues and PRs related to the V8 inspector protocol

Comments

@segrey
Copy link

segrey commented Jan 16, 2017

  • Version: 7.4.0
  • Platform: Windows 10

Debugger.scriptParsed events contain malformed "url" parameter values, like:

{
  "method": "Debugger.scriptParsed",
  "params": {
    "scriptId": "58",
    "url": "C:\\Users\\Sergey.Simonchik\\simple-example\\foo.js",
    "startLine": 0,
    "startColumn": 0,
    "endLine": 3,
    "endColumn": 3,
    "executionContextId": 1,
    "hash": "6A46C633B7646A730A332EE66076717AE7A6D0F1",
    "isLiveEdit": false,
    "sourceMapURL": "",
    "hasSourceURL": false
  }
}

Here "url" is set to "C:\\Users\\Sergey.Simonchik\\simple-example\\foo.js" which is an invalid URL.

According to https://chromium.googlesource.com/v8/v8/+/master/src/inspector/js_protocol.json, "url" parameter of "scriptParsed" event is defined as

{ "name": "url", "type": "string", "description": "URL or name of the script parsed (if any)." }

Probably, the expected value should be "file://C:\\Users\\Sergey.Simonchik\\simple-example\\foo.js"

@mscdex mscdex added the inspector Issues and PRs related to the V8 inspector protocol label Jan 16, 2017
@mscdex
Copy link
Contributor

mscdex commented Jan 16, 2017

/cc @nodejs/v8-inspector

@joshgav
Copy link
Contributor

joshgav commented Jan 19, 2017

/cc @roblourens

@lacmuch
Copy link

lacmuch commented Feb 4, 2017

Our problem is a little similar at #10672 . I can't map files in chrome workspace.

@Trott
Copy link
Member

Trott commented Jul 16, 2017

Should this remain open?

@bnoordhuis
Copy link
Member

bnoordhuis commented Jul 16, 2017

It's a legitimate bug: the inspector uses the script name as the URL, but it's a file path in node.js.

Although it can be overridden by inserting a //# sourceURL=... comment in the script source (and node.js could even do that automatically), it's probably better solved by making it programmatically overridable through the inspector's C++ API.

edit: pre-existing bug report: https://bugs.chromium.org/p/chromium/issues/detail?id=679144

@bnoordhuis bnoordhuis added the help wanted Issues that need assistance from volunteers or PRs that need help to proceed. label Jul 16, 2017
@TimothyGu
Copy link
Member

The Dev Tools frontend has already implemented a workaround: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/devtools/front_end/sdk/DebuggerModel.js?l=485&rcl=0a99285795ade2dd281995dee72fdb9e80d3fd6d

It's just a matter of getting that into V8.

@bnoordhuis
Copy link
Member

sourceURL.startsWith('/')

That won't work for Windows file paths.

@j3l11234
Copy link

j3l11234 commented Aug 9, 2017

╮(╯_╰)╭
I found a temp workaround.

//bootstrap.js
const fs = require('fs');
const vm = require('vm');

var mainCode = fs.readFileSync(__dirname + '/' + 'main.js');
vm.runInThisContext(module.constructor.wrap(mainCode), 'file://app/main.js')(exports, require, module, __filename, __dirname, process, global, Buffer);
node --inspect bootstrap.js

Then I use inline sourcemap in main.js
I works on my windows Chrome!

@hinell
Copy link

hinell commented Aug 31, 2017

@j3l11234 Tried your solution with no lack.
Also there are a few links referencing .ts files that emerged after that.
If I'm trying to edit it the pane is rendered blank.
screenshot_2

I have tested it with various paths in the 'File:/// ...path' but nothing changed..

@j3l11234
Copy link

j3l11234 commented Sep 1, 2017

╮(╯_╰)╭
@hinell
I use webpack,use devtool: 'inline-cheap-module-source-map',
Maybe you should use inline sourcemap

@kevinsimper
Copy link
Contributor

@j3l11234 this is definitely a "that one little that worked" 😱 👍

@j3l11234
Copy link

j3l11234 commented Sep 8, 2017

╮(╯_╰)╭
@kellygerber I think is the bug of node,
I try it for Chrome opening local html, The path uri is normal, so Chrome Devtools can parse the sourceMap.
But in node, the path uri is malformed, so So Chrome Devtools cant parse the sourceMap.
qq 20170907225006

@j3l11234
Copy link

╮(╯_╰)╭
@bnoordhuis @kevinsimper
I submit a issue to chrome
https://bugs.chromium.org/p/chromium/issues/detail?id=789569
It is bug of chrome devtools.

@roblourens
Copy link

roblourens commented Dec 8, 2017

When I run node with --experimental-modules, I see that it returns paths as file URLs in the url field. Does anyone know whether that will always be the case in the future? Intentional change?

@demurgos
Copy link
Contributor

Should be fixed in Node 10.12.

@bnoordhuis
Copy link
Member

It's been fixed in devtools (diff) so I'm going to go ahead and close this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues that need assistance from volunteers or PRs that need help to proceed. inspector Issues and PRs related to the V8 inspector protocol
Projects
None yet
Development

No branches or pull requests

13 participants