SAFE Browser 10.0.2 mock --- connectAuthorised errors

I have downloaded the latest version of the SAFE Browser. Live as well as mock. I can’t seem to make the connectAuthorised call to work.

The following is from within the SAFE Browser mock console:

It does not get past connectAuthorised and returns the infamous “Could not connect to the SAFE Network” error.

I have also encountered the exact same using the API playground by @hunterlester. (Using the same order: initialise, authorise and connectedAuthorised.) However, it only happens in the mock browser. It does not happen on the live Alpha 2 network.

Could anyone confirm this or spot a mistake in my process?

1 Like

@bzee I’d recommend using the latest versions of Peruse for dev (from the webId POC, using a newer version of safe-app-nodejs).

For authing apps in Peruse (such as the webId manager), this should get you going:

    const app = await safe.initialiseApp( );
    const authUri = await app.auth.genAuthUri( APP_INFO.permissions, APP_INFO.opts );
    const response = await safe.authorise( authUri );
    const connectedApp = await app.auth.loginFromUri( response );

For reference, the file for these actions:

You’d also need the 3.0 branch of the playground

1 Like

Thanks for the quick reply. The reason for using the SAFE Browser is that I’m trying to test if something works that uses the old API.

It’s unfortunate that the mock browser now seems broken. Although I can understand that it won’t be fixed anymore.

On the newer Peruse everything works. But that’s not my question. My problem is specifically with the 10.0.2 SAFE Browser (mock).

1 Like

Okay fair enough.

I dont see anything obviously wrong in your code.

This error can be thrown if the network configs are missing. But if you’ve downloaded the latest browser package, then it should be included (grabbing now to double check for me).

In the meantime, can you log the appHandle / uri just to check they are legit.

1 Like

I checked both the handle and URI to be legit. The exact same snippet works on the live network.

1 Like

@bzee if you are using the mock version of SAFE Beaker browser 0.10.2 you’ll need to set the env var NODE_ENV=dev in order to work properly, did you set this when trying with mock?

1 Like

I downloaded the mock browser from the releases page from GitHub.

Anyway, I just tried running the ‘SAFE Browser’ executable from an environment with the variable set. It makes no difference. So I assume it’s not needed.

1 Like

Can you please try by first removing you MockVault file and launching the mock browser again with the env set? (please make a backup of the mockvault we might be able to use it to reproduce the issue actually)

1 Like

Thanks, that seems to work! I do not remember having to set the environment variable for a mock build specifically (especially since it’s a hassle in comparison to just launching the executable). Has this changed?

1 Like

Ok, cool, then it’s just this same issue reported some time ago:
(cc: @nbaksalyar )

It hasn’t change, it’s been always like that for Beaker browser, and we were actually trying to remove it, and that’s what we did in Peruse already as it’s really not nice.

1 Like

Thanks for looking into this! Sorry for not seeing it was reported already on the JIRA; I’ve tried searching for the issue there briefly but could not find any.


No worries at all @bzee, I’m very glad you are trying things out, honestly. I edited my previous response in regard to the env var btw

1 Like

I’m confused. It if has always supposed to be like this, then there is no issue, right? Then this is just expected behavior.

I just looked at the README and it does not mention setting the variable before launching the executable. I also downloaded version 0.9, and it works without setting the environment variable. I’m quite sure I’ve never had to set NODE_ENV before launching the executable…

Yes it was always like this for our Beaker browser, so it’s expected that you need to set the env var when running it for mock. What it’s not expected is the error you had even when setting the env var which is reported in Jira.

In the README we have replaced the part where we explained setting the env var with the instruction to use another script which does it for you:
"If you're actively developing, you can run 'yarn mock' instead of 'yarn' in order to get the 'safe_client' libraries which use the 'MockVault' file rather than connecting to the SAFE Network."

I can only speculate with you having it set globally in your env? but I don’t know obviously, but if you look at the dev hub we even made sure to include that in the instructions:


Interesting! But, I’m not talking about the build process. I’m using pre-built releases from GitHub…

I just tested three versions: 0.8, 0.9 and 0.10. I first removed the mock vault file, then launched the version (mock) and used the playground to connect. Only 0.10 gives me the error ‘Could not connect …’, the other two do not.

This might be connected with the issue in 0.10?

Thanks for pointing me to that! Could it be added to the 5th step of the README too?

It tells how to package, but it doesn’t say the NODE_ENV should be set to dev when launching the mock build. (Which is why I thought the environment variable was never needed to be set before launching the mock version.)

I appreciate the answers. I’m sorry for the confusion…

Yeah, probably it’s a bug introduced in safe_client_libs v0.6.0 as browser v0.10.x upgraded it from v0.5.0:

BTW, I’m not sure if this is still happening in safe_app lib 0.7.x or 0.8.0.

Yes probably it can be added.

This topic was automatically closed after 60 days. New replies are no longer allowed.