GemWallet/gemwallet-extension

getNetwork() API not working

Closed this issue ยท 12 comments

Hello,

When I try to use the getNetwork() API, I get the following error in the console:

Unchecked runtime.lastError: The message port closed before a response was received.

image

The isConnected() API returns true but then impossible to get the network.

Hi Florent, I'll be looking into that, thanks for reporting it.

Hi @florent-uzio, I cannot reproduce your issue with the getNetwork not working, could you please share some code snippet for me to reproduce your issue?

Hi @FlorianBouron , you can check my repo, this line of code:

https://github.com/florent-uzio/xrpl-demo/blob/main/src/shared/contexts/gemwallet-connection-context.tsx#L29

You can uncomment the three lines (29, 30, 31).

You just need this to start the app after cloning it :

  • npm i
  • npm run dev

Let me know if you see the same issue or if it works for you.

I am reading different articles about this error such as:
https://technolads.com/unchecked-runtime-lasterror-the-message-port-closed/

I am using Brave:

[Version 1.49.120 Chromium: 111.0.5563.64](https://brave.com/latest/)

NPM dependencies:

"@gemwallet/api": "^2.2.0",
"vite": "^4.2.0"

I do have the error message, it comes from the communication between the content script and the background script.
Though, I am getting the network.
Thank you for the code, let me try to reproduce it with your repository.

Hey @florent-uzio ,
I have it working, I have created an MR right here: florent-uzio/gemwallet-demo#1
We are investigating the error in the console though, it doesn't block the use of GemWallet.
Thank you so much for your bug report.

@FlorianBouron

I've put up a pull request to add @florent-uzio! ๐ŸŽ‰

Hey @FlorianBouron thank you for your PR and your time on this :)

If the getNetwork works for you, feel free to close the issue :)

Sure, I will work on it a bit more today as I want to update regularly the network in the context in case for some reason the user changes the network in GemWallet while my app is open.
If that works fine I will close this issue :)

I can get the network with getNetwork() but the error message still appears in the console:

Unchecked runtime.lastError: The message port closed before a response was received.

I will close this issue as the api is working but it might be good to fix the error message in the console in the future :)

Thank you really appreciate it, we will be taking a look at it right after we are done with our next release.
Thank you so much for raising the issue.