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

Can't connect to firefox debugger #1509

Closed
afk-mario opened this issue Feb 19, 2019 · 12 comments · Fixed by #1669
Closed

Can't connect to firefox debugger #1509

afk-mario opened this issue Feb 19, 2019 · 12 comments · Fixed by #1669

Comments

@afk-mario
Copy link

Is this a feature request or a bug?

Bug

What is the current behavior?

I wan't to debug my addon using
web-ext run
I get error messages and after a while firefox crashes.

What is the expected or desired behavior?

Being able to connect to the debugger.

Version information (for bug reports)

  • Firefox version: 66.0b8 (64-bit)
  • Your OS and version: Arch Linux - Kernel: 4.20.8-arch1-1-ARCH
  • Paste the output of these commands:
node --version && npm --version && web-ext --version

v11.10.0
6.8.0
2.9.3

Source code available here

Output using --verbose output:

$ web-ext run
Applying config files: ./package.json, ./web-ext-config.js
[program.js][info] Version: 2.9.3
[cmd/run.js][info] Running web extension from /home/afk/projects/web-extensions/busca/dist
[util/manifest.js][debug] Validating manifest at /home/afk/projects/web-extensions/busca/dist/manifest.json
[extension-runners/firefox-desktop.js][debug] Creating new Firefox profile
[firefox/index.js][debug] Running Firefox with profile at /tmp/cbdc954a-e939-4708-b9fa-11cf8449812e
[firefox/index.js][debug] Checking if remote Firefox port 6005 is available
[firefox/remote.js][debug] Connecting to Firefox on port 6005
[firefox/index.js][debug] Executing Firefox binary: /usr/bin/firefox-developer-edition
[firefox/index.js][debug] Firefox args: -start-debugger-server 6005 -foreground -no-remote -profile /tmp/cbdc954a-e939-4708-b9fa-11cf8449812e -jsconsole --url about:debugging --url https://www.youtube.com/watch?v=C4Uc-cztsJo
[firefox/index.js][info] Use --verbose or open Tools > Web Developer > Browser Console to see logging
[firefox/remote.js][debug] Connecting to the remote Firefox debugger
[firefox/remote.js][debug] Connecting to Firefox on port 6005
[firefox/remote.js][debug] Retrying Firefox (0); connection error: Error: connect ECONNREFUSED ::1:6005
[firefox/remote.js][debug] Connecting to Firefox on port 6005
[firefox/remote.js][debug] Retrying Firefox (1); connection error: Error: connect ECONNREFUSED ::1:6005
[firefox/remote.js][debug] Connecting to Firefox on port 6005
[firefox/index.js][debug] Firefox stdout: 1550562619969	addons.webextension.screenshots@mozilla.org	WARN	Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: mozillaAddons
[firefox/index.js][debug] Firefox stdout: 1550562619969	addons.webextension.screenshots@mozilla.org	WARN	Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: resource://pdf.js/
1550562619969	addons.webextension.screenshots@mozilla.org	WARN	Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: about:reader*
[firefox/remote.js][debug] Retrying Firefox (2); connection error: Error: connect ECONNREFUSED ::1:6005
[firefox/remote.js][debug] Connecting to Firefox on port 6005
[firefox/remote.js][debug] Retrying Firefox (3); connection error: Error: connect ECONNREFUSED ::1:6005
[firefox/remote.js][debug] Connecting to Firefox on port 6005
[firefox/index.js][debug] Firefox stdout: Started debugger server on 6005
[firefox/remote.js][debug] Retrying Firefox (4); connection error: Error: connect ECONNREFUSED ::1:6005
[firefox/remote.js][debug] Connecting to Firefox on port 6005
[firefox/remote.js][debug] Retrying Firefox (5); connection error: Error: connect ECONNREFUSED ::1:6005
[firefox/remote.js][debug] Connecting to Firefox on port 6005
@Rob--W
Copy link
Member

Rob--W commented Feb 28, 2019

Can you show the full log? Was your system under heavy resource constraints?

This is my log after running web-ext run from your repo, on ArchLinux, using web-ext 2.9.2 (whose web-ext run behavior is identical to your 2.9.3) and Firefox Developer Edition 66.0b11. Firefox starts, and as the log shows, the debugger manages to connect eventually.

[firefox/index.js][debug] Running Firefox with profile at /tmp/3d298752-b47a-46cd-adda-a6598b40f614
[firefox/index.js][debug] Checking if remote Firefox port 6005 is available
[firefox/remote.js][debug] Connecting to Firefox on port 6005
[firefox/remote.js][debug] Connected to the remote Firefox debugger on port 6005
[firefox/index.js][debug] Remote Firefox port 6005 is in use (retries remaining: 10)
[firefox/remote.js][debug] Connecting to Firefox on port 6006
[firefox/remote.js][debug] Received "end" from Firefox client
[firefox/index.js][debug] Executing Firefox binary: /usr/bin/firefox-developer-edition
[firefox/index.js][debug] Firefox args: -start-debugger-server 6006 -foreground -no-remote -profile /tmp/3d298752-b47a-46cd-adda-a6598b40f614 -jsconsole --url about:debugging --url https://www.youtube.com/watch?v=C4Uc-cztsJo
[firefox/index.js][info] Use --verbose or open Tools > Web Developer > Browser Console to see logging
[firefox/remote.js][debug] Connecting to the remote Firefox debugger
[firefox/remote.js][debug] Connecting to Firefox on port 6006
[firefox/remote.js][debug] Retrying Firefox (0); connection error: Error: connect ECONNREFUSED 127.0.0.1:6006
[firefox/remote.js][debug] Connecting to Firefox on port 6006
[firefox/remote.js][debug] Retrying Firefox (1); connection error: Error: connect ECONNREFUSED 127.0.0.1:6006
[firefox/remote.js][debug] Connecting to Firefox on port 6006
[firefox/index.js][debug] Firefox stdout: 1551363384078 addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: mozillaAddons
[firefox/index.js][debug] Firefox stdout: 1551363384079 addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: resource://pdf.js/
1551363384079   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: about:reader*
[firefox/remote.js][debug] Retrying Firefox (2); connection error: Error: connect ECONNREFUSED 127.0.0.1:6006
[firefox/remote.js][debug] Connecting to Firefox on port 6006
[firefox/remote.js][debug] Retrying Firefox (3); connection error: Error: connect ECONNREFUSED 127.0.0.1:6006
[firefox/remote.js][debug] Connecting to Firefox on port 6006
[firefox/index.js][debug] Firefox stdout: Started debugger server on 6006
[firefox/remote.js][debug] Retrying Firefox (4); connection error: Error: connect ECONNREFUSED 127.0.0.1:6006
[firefox/remote.js][debug] Connecting to Firefox on port 6006
[firefox/remote.js][debug] Connected to the remote Firefox debugger on port 6006
[firefox/remote.js][debug] installTemporaryAddon: {"addon":{"id":"7c9bf273d09da91dee9d166aa565400ea44e38a8@temporary-addon","actor":false},"from":"server2.conn0.addonsActor3"}
[firefox/remote.js][info] Installed /tmp/busca/dist as a temporary add-on
[cmd/run.js][info] The extension will reload if any source file changes
[util/file-filter.js][debug] Resolved path **/*.xpi with sourceDir /tmp/busca/dist to /tmp/busca/dist/**/*.xpi
[util/file-filter.js][debug] Resolved path **/*.zip with sourceDir /tmp/busca/dist to /tmp/busca/dist/**/*.zip
[util/file-filter.js][debug] Resolved path **/.* with sourceDir /tmp/busca/dist to /tmp/busca/dist/**/.*
[util/file-filter.js][debug] Resolved path **/.*/**/* with sourceDir /tmp/busca/dist to /tmp/busca/dist/**/.*/**/*
[util/file-filter.js][debug] Resolved path **/node_modules with sourceDir /tmp/busca/dist to /tmp/busca/dist/**/node_modules
[util/file-filter.js][debug] Resolved path **/node_modules/**/* with sourceDir /tmp/busca/dist to /tmp/busca/dist/**/node_modules/**/*
[watcher.js][debug] Watching for file changes in /tmp/busca/dist
[extension-runners/index.js][info] Press R to reload (and Ctrl-C to quit)
[firefox/remote.js][debug] Received message from client: {"from":"root","type":"tabListChanged"}
[firefox/remote.js][debug] Received "end" from Firefox client
[firefox/index.js][debug] Firefox stderr: [Parent 2926, Gecko_IOThread] WARNING: pipe error (103): Connection reset by peer: file /build/firefox-developer-edition/src/mozilla-unified/ipc/chromium/src/chrome/common/ipc_channel_posix.cc, line 357
[firefox/index.js][debug] Firefox closed

@afk-mario
Copy link
Author

afk-mario commented Mar 2, 2019

I just tried again using Firefox 66.0b12 and got the same problem, from a clean boot so wasn't running enything else.

yarn run v1.13.0
$ web-ext run
Applying config files: ./package.json, ./web-ext-config.js
[program.js][info] Version: 2.9.3
[cmd/run.js][info] Running web extension from /home/afk/projects/web-extensions/busca/dist
[util/manifest.js][debug] Validating manifest at /home/afk/projects/web-extensions/busca/dist/manifest.json
[extension-runners/firefox-desktop.js][debug] Creating new Firefox profile
[firefox/index.js][debug] Running Firefox with profile at /tmp/35a26d32-ae73-4680-a677-d51dba336f93
[firefox/index.js][debug] Checking if remote Firefox port 6005 is available
[firefox/remote.js][debug] Connecting to Firefox on port 6005
[firefox/index.js][debug] Executing Firefox binary: /usr/bin/firefox-developer-edition
[firefox/index.js][debug] Firefox args: -start-debugger-server 6005 -foreground -no-remote -profile /tmp/35a26d32-ae73-4680-a677-d51dba336f93 -jsconsole --url about:debugging --url https://www.youtube.com/watch?v=C4Uc-cztsJo
[firefox/index.js][info] Use --verbose or open Tools > Web Developer > Browser Console to see logging
[firefox/remote.js][debug] Connecting to the remote Firefox debugger
[firefox/remote.js][debug] Connecting to Firefox on port 6005
[firefox/remote.js][debug] Retrying Firefox (0); connection error: Error: connect ECONNREFUSED ::1:6005
[firefox/remote.js][debug] Connecting to Firefox on port 6005
[firefox/index.js][debug] Firefox stdout: 1551553233579	addons.webextension.screenshots@mozilla.org	WARN	Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: mozillaAddons
[firefox/index.js][debug] Firefox stdout: 1551553233579	addons.webextension.screenshots@mozilla.org	WARN	Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: resource://pdf.js/
1551553233579	addons.webextension.screenshots@mozilla.org	WARN	Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: about:reader*
[firefox/remote.js][debug] Retrying Firefox (1); connection error: Error: connect ECONNREFUSED ::1:6005
[firefox/remote.js][debug] Connecting to Firefox on port 6005
[firefox/remote.js][debug] Retrying Firefox (2); connection error: Error: connect ECONNREFUSED ::1:6005

... repeat 247 times ...

[firefox/remote.js][debug] Connecting to Firefox on port 6005
[firefox/remote.js][debug] Retrying Firefox (250); connection error: Error: connect ECONNREFUSED ::1:6005
[firefox/remote.js][debug] Connect to Firefox debugger: too many retries
[program.js][error] 
Error: connect ECONNREFUSED ::1:6005
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1083:14)

[program.js][error] Error code: ECONNREFUSED

[program.js][debug] Command executed: run
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@ghost
Copy link

ghost commented Mar 23, 2019

I'm having the same troubles with Firefox 65.0.1 on Solus.. addon debugger is enabled. My configuration couldn't be simpler, I'm just using the borderify webextension "hello world" tutorial provided by Mozilla, and ran web-ext run --verbose.

$ web-ext --version && node --version
3.0.0
v10.15.3

@Rob--W
Copy link
Member

Rob--W commented Mar 24, 2019

@arcooke Is your issue consistently reproducible? I tried to recreate the problem from the original report (using ArchLinux and the same versions of web-ext and firefox-developer-edition), but I wasn't able to replicate the issue.

@ghost
Copy link

ghost commented Mar 24, 2019

@Rob--W

So about that.. I'm sorry. I did the same thing you warned about in your first reply in this thread.. it was throwing these errors, but connecting eventually. I didn't notice it had a 250-retry timeout. I hope you didn't spend any extra time as a result of my report

I did manage to get it to error out a few times, but it's probably normal and unrelated to the original post. If I close the web-ext session and relaunch a new one too soon, sometimes it will show an error message and continue through 250 failed retries even if I close the dialog box.

image

However, this only happens if I relaunch a new web-ext session too fast, the previous debugger probably hadn't cleanly disconnected yet or something. So likely unrelated, and you can ignore my posts here. This is not a problem for me.

@Rob--W
Copy link
Member

Rob--W commented Mar 24, 2019

@rpl To reduce the odds of reusing a port that may still be in use, what do you think of selecting a known-free port (e.g. like we do at

chooseLocalTcpPort(): Promise<number> {
return new Promise((resolve) => {
const srv = net.createServer();
// $FLOW_FIXME: flow has his own opinions on this method signature.
srv.listen(0, () => {
const freeTcpPort = srv.address().port;
srv.close();
resolve(freeTcpPort);
});
});
}
)? That will not only reduce the potential for failure, but also results in faster startups when multiple instances of web-ext are running.

@rpl
Copy link
Member

rpl commented Mar 25, 2019

@Rob--W 👍 sure, sounds reasonable to me too

@caitmuenster
Copy link

If this is your first contribution, please refer to https://github.com/mozilla/web-ext/blob/master/CONTRIBUTING.md for how to get started.

Mentor: @rpl

@arunikayadav42
Copy link

Can somebody help me get started with this issue please ^_^

@rpl
Copy link
Member

rpl commented May 15, 2019

Can somebody help me get started with this issue please ^_^

@arunikayadav42 Sure, as Rob mentioned in #1509 (comment) we would like to replace the strategy currently used in the src/firefox/index.js module with the strategy we are already using in the "firefox-android extension runner" (which you can see in the code fragment linked in Rob's comment, it is basically temporarily starting a tcp server to get a free tcp port number).

In src/firefox/index.js, the port to use is currently choosen using the strategy implemented in defaultRemotePortFinder:

export async function defaultRemotePortFinder(
{
portToTry = REMOTE_PORT,
retriesLeft = 10,
connectToFirefox = defaultFirefoxConnector,
}: RemotePortFinderParams = {}
): Promise<number> {
log.debug(`Checking if remote Firefox port ${portToTry} is available`);

(which starts from a statically defined port number, const REMOTE_PORT = 6005, and if the connection is refused it tries the next port number).

Then the defaultRemotePortFinder is called by the run method here:

const remotePort = await findRemotePort();

and the remotePort number is passed to the fxRunner call here:

'listen': remotePort,

These should be the most relevant pieces of code that you will have to carefully read and understand (no worries, we are here to help with that ;-)) and then apply the needed changes.

Let me know if you have more questions or you have met some issue while working on the changes.

Best,
Luca

@rbrishabh
Copy link
Contributor

rbrishabh commented Jul 22, 2019

Hey! Can I take this up?

I know how to get started, read all the comments, just want to know if it's still relevant.

@rpl
Copy link
Member

rpl commented Jul 22, 2019

Hey! Can I take this up?

I know how to get started, read all the comments, just want to know if it's still relevant.

@rbrishabh sure, feel free to take this. In #1509 (comment) there are some pointers related to the kind of change that we are aiming for.

@rpl rpl closed this as completed in #1669 Sep 24, 2019
rpl pushed a commit that referenced this issue Sep 24, 2019
… remote debugging server (#1669)

This patch changes how web-ext run choose a free tcp port for the Firefox Desktop remote debugging server. 
This change aims to reduce the chances of reusing a port that may still being in use, and then fix (or at least reduce the incidence of) #1509
LoveIsGrief added a commit to LoveIsGrief/hoverzoom that referenced this issue Aug 19, 2023
extesy pushed a commit to extesy/hoverzoom that referenced this issue Aug 20, 2023
* chore: Update web-ext to latest version

Fixes mozilla/web-ext#1509

* fix: panning locked images+videos on firefox

Pass the event object to the function as it's used there.

Fix #1036
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants