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

0.13 beta4 - devtools / source not found when clicking links from console #4269

Open
maxbarry opened this issue Jan 18, 2016 · 11 comments
Open

Comments

@maxbarry
Copy link

In beta4 on Ubuntu 15.10 64-bit, clicking a link to source from the console opens a new ERR_FAILED browser window with "This webpage is not available," rather than displaying the source within devtools:

package.json:

{
  "name": "sample",
  "main": "index.html"
}

index.html:

<!DOCTYPE html>
<html>
  <head>
    <title>Hello World!</title>
  </head>
  <body>
    <h1>Hello World!</h1>
    <script>
    nw.require('./myModule.js');
    </script>
  </body>
</html>

myModule.js:

console.log("Hello.");

To reproduce:

  1. Run nwjs-sdk-v0.13.0-beta4-linux-x64/nw .
  2. Right-click -> "Inspect background page"
  3. See output: Hello. /home/max/code/sports/test/myModule.js:1
  4. Click link to source

Result: New window opens. URL is "chrome-devtools://devtools/home/max/code/test/myModule.js". Title is "chrome-devtools://devtools/home/max/code/test/myModule.js is not available - NW.js". Content is: "This webpage is not available | ERR_FAILED | The webpage at chrome-devtools://devtools/home/max/code/test/myModule.js might be temporarily down or it may have moved permanently to a new web address."

Notably, this only happens when myModule.js is included in the above fashion. If instead index.html includes it like this:

<script src="myModule.js"></script>

... then it works, except that it doesn't seem to correctly link to the right line number, and the output must be viewed via "Inspect" rather than "Inspect background page".

@maxbarry
Copy link
Author

I also just posted in #4121, which is closed, but still exhibiting a similar crashing bug for me.

@ghostoy
Copy link
Member

ghostoy commented Jan 19, 2016

The root cause is that NW crashes when trying to opening a new window in a tab, which was the behavior of Chrome browser. It will happen in following scenarios:

@rogerwang
Copy link
Member

Fixed in git and will be available in the next nightly build.

ghostoy pushed a commit to ghostoy/nw.js that referenced this issue Jan 22, 2016
rogerwang added a commit that referenced this issue Jan 23, 2016
rogerwang pushed a commit to nwjs/chromium.src that referenced this issue Feb 19, 2016
By default, the disposition is `NEW_FOREGROUND_TAB`, which will be
opened in a browser tab.

Fixed nwjs/nw.js#4269 nwjs/nw.js#4121
@maxbarry
Copy link
Author

Just checked back in and this is still happening in RC4:

package.json:

{
  "name": "sample",
  "main": "index.html"
}

index.html:

<!DOCTYPE html>
<html>
  <head>
    <title>Hello World!</title>
  </head>
  <body>
    <h1>Hello World!</h1>
    <script src="myModule.js"></script>
  </body>
</html>

myModule.js:

console.log("Loading myModule2...");

nw.require('./myModule2');

myModule2.js:

console.log("Greetings from myModule2!");

myTestError();

There are two ways to get the buggy behavior with this test case. Here is the first:

  1. ../nwjs-sdk-v0.13.0-rc4-linux-x64/nw .
  2. Right click -> "Inspect background page"
  3. Left click on "Console" tab
  4. See console output: Greetings from myModule2.js! /home/max/code/test2/myModule2.js:1
  5. Left click on the filename in the above output

Result: New browser window opens with URL chrome-devtools://devtools/home/max/code/test2/myModule2.js. Browser window says: "This site can’t be reached. The web page at chrome-devtools://devtools/home/max/code/sports/test2/myModule2.js might be temporarily down or it may have moved permanently to a new web address."

Second method:

  1. ../nwjs-sdk-v0.13.0-rc4-linux-x64/nw .
  2. Right click -> "Inspect"
  3. Left click on "Console" tab
  4. See console output: Uncaught ReferenceError: myTestError is not defined /home/max/code/test2/myModule2.js:3
  5. Left click on the filename in the above output

Result: Same as before ("The site can't be reached.").

In this scenario, clicking the first line of output (Loading myModule2... myModule.js:1) works, but clicking the second doesn't.

Ubuntu 15.10 64-bit.

@rogerwang rogerwang reopened this Mar 22, 2016
@rogerwang rogerwang assigned rogerwang and unassigned ghostoy Mar 22, 2016
@rogerwang
Copy link
Member

@ghostoy please take this issue. FYI the link href handling is WebInspector.linkifyURLAsNode of third_party/WebKit/Source/devtools/front_end/components/Linkifier.js. After giving the "file://" prefix it can be opened correctly with browser window. But ideally we need it to be loaded in the Resource pane as the other JS file.

@ghostoy
Copy link
Member

ghostoy commented Mar 28, 2016

There are three internal causes:

  • The issue of clicking links in devtools of background page is due to GC. It's fixed in my PR (Fix broken links generated from Node modules in DevTools node#4).
  • The reason of clicking links in current window is because the script is executed in the background page rather than in current window. So scripts is not available in current window's devtools. Similarly you will experience similar issue when getting errors in a different context in Chrome, such as calling opener.func() which throws exceptions. So I won't fix it.
  • The popup windows contains an invalid link is caused by the filename provided by Node. I'll fix it later.

ghostoy pushed a commit to ghostoy/node that referenced this issue Mar 28, 2016
Compiled scripts from Node were set to weak, which caused the script
object in V8 being GCed shortly. Hence links of the script shown in
console of DevTools become invalid after GC. This patch saved compiled
scripts from Node globally to survival from GC.

The patch also transformed the filename representation of Node module
into `file://` protocol. This fixed links of scripts shown in DevTools
that are not loaded in current context.

Fixed nwjs/nw.js#4269
@rogerwang rogerwang modified the milestones: 0.14.0, 0.13.x Apr 2, 2016
@maxbarry
Copy link
Author

maxbarry commented Apr 6, 2016

Sorry, more of a question than a bug report, but I just noticed this is now milestoned for 0.14, and am a bit alarmed at the idea of not being able to use 0.13 at all.

Is there a workaround for this bug? I don't understand how I can work with 0.13 since I can't debug. The only thing I can think of is to merge the entire app into a single file so that it doesn't 'require' anything.

@rogerwang
Copy link
Member

@ghostoy had a fix. It's still under review and it's marked as 0.14 because the underlying change is important. We want to make sure it doesn't have any side effects. @ghostoy can we have some way to enable it only in SDK build?

btw, 0.14 would be released soon with Chromium 50 stable in 1-2 weeks.

@rogerwang
Copy link
Member

PS, the patch still has a chance to be in 0.13.x although it's marked as 0.14.

@rogerwang rogerwang assigned rogerwang and unassigned ghostoy Apr 7, 2016
ghostoy pushed a commit to ghostoy/node that referenced this issue Apr 7, 2016
Compiled scripts from Node were set to weak, which caused the script
object in V8 being GCed shortly. Hence links of the script shown in
console of DevTools become invalid after GC. This patch saved compiled
scripts from Node globally to survival from GC.

The patch also transformed the filename representation of Node module
into `file://` protocol. This fixed links of scripts shown in DevTools
that are not loaded in current context.

Fixed nwjs/nw.js#4269
ghostoy pushed a commit to ghostoy/node that referenced this issue Apr 7, 2016
Compiled scripts from Node were set to weak, which caused the script
object in V8 being GCed shortly. Hence links of the script shown in
console of DevTools become invalid after GC. This patch saved compiled
scripts from Node globally to survival from GC.

Fixed nwjs/nw.js#4269
@rogerwang rogerwang modified the milestones: 0.14.0, 0.14.x Apr 14, 2016
@IssueHuntBot
Copy link

@loadbalance-sudachi-kun funded this issue with $256. Visit this issue on Issuehunt

@championpaddler
Copy link

@maxbarry I am claiming this issue.

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

No branches or pull requests

6 participants