JabRef / JabRef-Browser-Extension

Browser extension for JabRef to allow importing of new items directly from the browser.
https://www.jabref.org/
GNU Affero General Public License v3.0
84 stars 22 forks source link

Error while sending to JabRef #400

Open Krzmbrzl opened 2 years ago

Krzmbrzl commented 2 years ago

This issue seems to be very similar to #398 #278 and #382. However, I think in my case the issue might be slightly different (I'll leave that up to you to decide).

I use the Firefox browser extension and when I try to import e.g. https://pubs.rsc.org/en/content/articlelanding/2021/cp/d1cp02640b into my bibliography, I get the "Error while sending to JabRef" error message. When I check the browser console as suggested, I see

Ignoring unsupported entryTypes: largest-contentful-paint. d1cp02640b:13:23642
No valid entryTypes; aborting registration. d1cp02640b:13:23642
Ignoring unsupported entryTypes: layout-shift. d1cp02640b:13:23738
Some cookies are misusing the recommended “SameSite“ attribute 6
Google Publisher Tags is being shimmed by Firefox. See https://bugzilla.mozilla.org/show_bug.cgi?id=1713685 for details. sandbox eval code:1:9
JQMIGRATE: Migrate is installed, version 1.4.1 vendor.min.js:16:574
Legacy Google Analytics is being shimmed by Firefox. See https://bugzilla.mozilla.org/show_bug.cgi?id=1487072 for details. sandbox eval code:1:9
Loading failed for the <script> with source “https://js-agent.newrelic.com/nr-spa-1212.min.js”. d1cp02640b:1:1
Relative positioning of table rows and row groups is now supported. This site may need to be updated because it may depend on this feature having no effect. vendor.min.js:14:97025
JabRef: Got task to convert  
Array [ {…} ]
​
length: 0
​
<prototype>: Array []
  to BibTeX bibtexConverter.js:240:11
JabRef: Converting item(s) to BibLaTeX:  
Array [ {…} ]
​
length: 0
​
<prototype>: Array []
bibtexConverter.js:7:11

Note that everything up to the first JabRef: line is also present when visiting the site as-is without attempting to use the JabRef browser extension. Therefore, I suspect that these are unrelated.

In the extension's settings it says: Connection status: Attempt to postMessage on disconnected port Websocket status: Websocket client not started

From this it seems to me as if some underlying process could not be started and maybe the import is failing because of that?

I do have the extension working on another PC of mine (running KDE Neon (built on Ubuntu 20.04)) but on the other (OpenSuse Leap 15.3) I get this error.

How can I debug this further?

LyzardKing commented 2 years ago

Which version of Jabref (and the web connector) are you using?

Krzmbrzl commented 2 years ago

JabRef 5.5--2022-01-17--27a05c7 Linux 5.3.18-59.40-default amd64 Java 16.0.2 JavaFX 17.0.1+1

Browser extension v2.4

LyzardKing commented 2 years ago

Just a couple more questions: How is jabref installed? deb, snap, or flatpak? If you go to the extension settings, does it say that the connection is successful?

Krzmbrzl commented 2 years ago

How is jabref installed?

On the machine where everything works: as deb On the machine that is causing troubles: as rpm

If you go to the extension settings, does it say that the connection is successful?

No, it says

Connection status: Attempt to postMessage on disconnected port Websocket status: Websocket client not started

LyzardKing commented 2 years ago

Ok. Try looking at https://docs.jabref.org/collect/jabref-browser-extension You can find the manual instructions for linux. There might be an issue with automatic installation of the extension parts.

First, if you can verify the content of this file: /opt/jabref/lib/native-messaging-host/firefox/org.jabref.jabref.json It would be very useful to debug this issue. In there you should find the path to the firefox browser on your system

(If the firefox browser is installed via flatpak it won't work, not without further changes)

tobiasdiez commented 2 years ago

Usually, the error message "Attempt to postMessage on disconnected port" signals that something is wrong with the setup around the org.jabref.jabref.json file. Usually, the browser console contains more information (for example, where it looked for the json file) but that doesn't seem the case for you.

As @LyzardKing said, please go through the manual instructions to make sure your setup is correct. If you managed to fix the issue in this way, please report back how you did it so that we can improve our installer. It would also be nice if you could help with https://github.com/JabRef/JabRef-Browser-Extension/issues/405 in a couple of days. Thanks!

Krzmbrzl commented 2 years ago

I will do as instructed as soon as I am back at the machine with the faulty setup (probably within this week) and I will report my findings here :+1:

Krzmbrzl commented 2 years ago

In there you should find the path to the firefox browser on your system

Where exactly? The content of this file looks like this for me:

{
  "name": "org.jabref.jabref",
  "description": "JabRef",
  "path": "/opt/jabref/lib/jabrefHost.py",
  "type": "stdio",
  "allowed_extensions": [
    "browserextension@jabref.org",
    "@jabfox"
  ]
}

so no Firefox path in there. The file sits at /usr/lib/mozilla/native-messaging-hosts as expected, so I assume this part of the installation process worked as intended.

@tobiasdiez Today the new error message page popped up and I really do like it. It's much better than the old style of presenting the error message. However, the instructions

Common reasons for this error include:

The files jabref-firefox.json and jabref-chrome.json are not placed next to JabRef.bat. The path to jabref-firefox.json or jabref-chrome.json specified in the registry is not correct.

appears to be windows-only, correct? In that case, I'd either try to detect the OS and change the message accordingly or just add something like "On Windows..." to these instructions to make clear that for other OS, you'll have to check the linked instructions page yourself.

Krzmbrzl commented 2 years ago

Btw. opening the Browser console on that new error page now includes a seemingly relevant entry:

ExtensionError: No such native application org.jabref.jabref ExtensionUtils.jsm:58:5 ExtensionError resource://gre/modules/ExtensionUtils.jsm:58 startupPromise resource://gre/modules/NativeMessaging.jsm:83

I'm not quite sure what to do with this message, but I think it seems likely that this is the root cause of the issue I am seeing.

Krzmbrzl commented 2 years ago

Apparently the abovementioned error is emitted from here:

this.startupPromise = NativeManifests.lookupManifest(
      "stdio",
      application,
      context
    )
      .then(hostInfo => {
        // Report a generic error to not leak information about whether a native
        // application is installed to addons that do not have the right permission.
        if (!hostInfo) {
          throw new ExtensionError(`No such native application ${application}`);
        }

inside /gre/modules/NativeMessaging.jsm. The comment appears interesting as it seems to suggest that there is some kind of permission problem going on here. However, the respective JSON file (and the script linked in it) should be readable and executable for everyone. Is this perhaps more of a Firefox-internal permission handling?

LyzardKing commented 2 years ago

@Krzmbrzl The version that doesn't work is the rpm one, right? Does the python file in /opt/jabref/lib/jabrefHost.py exist?

Krzmbrzl commented 2 years ago

The version that doesn't work is the rpm one, right?

yep

Does the python file in /opt/jabref/lib/jabrefHost.py exist?

$ ll /opt/jabref/lib/jabrefHost.py
-rwxr-xr-x 1 root root 3767 17. Jan 21:34 /opt/jabref/lib/jabrefHost.py
LyzardKing commented 2 years ago

Ok, and the firefox version is rpm as well, right? Not a snap/flatpak.

If you execute the python script in the command line it should start the loop, and you shouldn't see anything, although it should not stop. If you can try that, let me know. Then you can stop it with CTRL-C

Krzmbrzl commented 2 years ago

Ok, and the firefox version is rpm as well, right? Not a snap/flatpak.

I think so. It came preinstalled on OpenSuse. Is there a way to check to make this sure? EDIT: It appears snap isn't even installed on my system and zypper tells me that the MozillaFirefox package is installed. Therefore, I think it is save to say that it is indeed installed as a RPM.

If you execute the python script in the command line it should start the loop, and you shouldn't see anything, although it should not stop. If you can try that, let me know. Then you can stop it with CTRL-C

Yep, that works as described

Krzmbrzl commented 2 years ago

Is there anything I can do to further debug the message I found in the browser console earlier?

LyzardKing commented 2 years ago

@Krzmbrzl could you check that jabref is installed in /opt and that this file exists?

/opt/jabref/lib/jabrefHost.py

Krzmbrzl commented 2 years ago

@LyzardKing yes it JabRef is installed in /opt and the mentioned file also exists:

$ ll /opt/jabref/lib/jabrefHost.py
-rwxr-xr-x 1 root root 3767 17. Jan 21:34 /opt/jabref/lib/jabrefHost.py
GorkaAbad commented 2 years ago

I'm also having the same issue in Ubuntu 22.04

EDIT: I managed to make it work out of the box with firefox nightly.