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

README says safe_browser uses node v8 #703

Closed
2 of 3 tasks
happybeing opened this issue Apr 29, 2019 · 14 comments
Closed
2 of 3 tasks

README says safe_browser uses node v8 #703

happybeing opened this issue Apr 29, 2019 · 14 comments

Comments

@happybeing
Copy link

Prerequisites

  • Using yarn
  • Using an up-to-date master branch
  • Link to stacktrace in a Gist (for bugs)

Expected Behavior

I'm running a local dev browser (no mods yet) with yarn link to a local safe_app_nodejs (no mods yet). I expect the browser to start and function as normal.

Current Behavior

When I run the browser with NODE_ENV=dev yarn dev the console includes uncaught exceptions which report that safe_app_nodejs is using a different node version to the browser. The browser window doesn't appear.

The Browser README says:

Node.js ^8.0.0 (we recommend installing it via nvm)

safe_app_nodejs README says:

Node.js ^10.0.0 (we recommend installing it via nvm)

Possible Solution

Changing the browser to use nodejs v10 appears to fix this issue, so I think the safe_browser README is incorrect. What is the correct version of nodejs to use with SAFE Browser?

Steps to Reproduce (for bugs)

Context

Your Environment

  • Operating System and version : Ubuntu 18.10
@calumcraig
Copy link

calumcraig commented Apr 29, 2019

Hi Mark, thanks for flagging this issue.

I can confirm that I am able to reproduce the above behaviour on a fresh clone of the master branch of the browser repo.

Another workaround is to run yarn first. NODE_ENV=dev yarn dev will then successfully launch the browser. My node version is 8.16.

@happybeing
Copy link
Author

happybeing commented Apr 29, 2019 via email

@bochaco
Copy link
Member

bochaco commented Apr 29, 2019

We are considering to upgrade everything to the very latest version of nodejs (v12) as that would presumably also help us in getting electron upgraded to v5 in the browser and some of the other example apps. Any thoughts about this?

@happybeing
Copy link
Author

We are considering to upgrade everything to the very latest version of nodejs (v12) as that would presumably also help us in getting electron upgraded to v5 in the browser and some of the other example apps. Any thoughts about this?

@bochaco I don't really know nodejs or the different versions well enough to understand the implications (evidence below! 😉). I see that Solid appear to be using v10 (e.g. for solid-auth-client which I'm working on).

On the face of it as much as possible using the same version of node seems to be desirable to avoid problems with using different node versions for different libraries. But I don't know the implications of different versions of node on the codebase, working with other modules etc. My instinct is to go for latest stable version, but it isn't always right!


Ooops! @calumcraig I'm on dev branch because I want the latest tweaks (e.g. for window.eval()). Sorry forgot about that.

And contrary to the OP I have not found a way to get SAFE Browser working with local safe_app_nodejs, I may just have forgotten to link to yarn link "@maidsafe/safe-node-app"

To test your solution I did the following, but this still gives the error:

nvm use 8 && rm -rf node_modules && yarn && yarn link "@maidsafe/safe-node-app" && NODE_ENV=dev yarn dev

What I thought I'd done to fix it, was this, but this also still gives the error:

nvm use 10 && rm -rf node_modules && yarn && yarn link "@maidsafe/safe-node-app" && NODE_ENV=dev yarn dev

If I omit the yarn link as follows it works (but obviously isn't using my local safe_nodejs_app):

nvm use 10 && rm -rf node_modules && yarn && NODE_ENV=dev yarn dev

The error is back if in safe_browser I then do:

yarn link "@maidsafe/safe-node-app"  && NODE_ENV=dev yarn dev

I'm confused here, because safe_nodejs_app doesn't have anything built. I've just forked it and in safe_app_nodejs done yarn && yarn link.

So my problem seems not to be the node version in safe_browser, but that I'm linking to safe_app_nodejs - maybe I need that to be on dev branch too... um, no. I get build errors on dev branch when I do rm -rf node_modules && yarn. master is fine, but as noted I can't get it working with SAFE Browser.

So I have not yet managed to get local SAFE Browser to work with a local safe_app_nodejs ☹️ Help appreciated!

What I'm really trying to do though is: ensure my version of solid-auth-client is being used by a SAFE Browser web app. I have not confirmed this 100% but am pretty sure that the published rdflib/solid-auth-client (which is used by safe_app_nodejs) is being inserted into the window object by SAFE Browser, and blocking access to my version by my web app. I'm pretty sure this is the case because my version is used in Firefox, but I get a warning from solid-auth-client about SolidAuthClient being loaded twice when I'm running in SAFE Browser.

My plan was to get safe_app_nodejs to use my rdflib/solid-auth-client, but ultimately I think it is a bug that modules used by SAFE Browser/safe_app_nodejs are overriding the ones selected by a web app. If that is indeed what's happening.

@happybeing
Copy link
Author

UPDATE: I may have found a solution to using my rdflib/solid-auth-client. I am able to link to rdflib in safe_browser and so don't seem to need to also link to safe_app_nodejs. Looking into this now.

So I still don't know how to get local safe_app_nodejs/master to work with local safe_browser/dev but I don't think I need to do this now, so not urgent.

@calumcraig
Copy link

calumcraig commented Apr 29, 2019

Ooops! @calumcraig I'm on dev branch because I want the latest tweaks (e.g. for window.eval()). Sorry forgot about that.

Ah, OK, I'll try and reproduce on dev like yourself and let you know if I hit the same issues.

@calumcraig
Copy link

Hmm, @theWebalyst I've switched to the dev branch and I'm able to launch the browser OK using NODE_ENV=dev yarn dev... I haven't changed anything else since my previous post so my node version is 8.16. I'm on Linux Mint 19 (which is based on Ubuntu 18.04). I'll need to defer to @bochaco et al who have greater knowledge of the technology in use here.

@happybeing
Copy link
Author

Just to check @calumcraig were you using yarn link safe-app-nodejs in safe_browser to use a local copy of safe_app_nodejs. I ask, because if you weren't this problem doesn't arise.

Also, just to re-affirm this is no longer an issue for me atm (as I don't seem to nee to use a local safe-app-nodejs).

Instead my problem is that in my web app I can't use forked versions of rdflib.js/solid-auth-client with SAFE Browser because the modules it also uses rdflib.js, and causes those versions of rdflib.js/solid-auth-client to be 'imposed' on my web app. I've raised a separate issue #708

@bochaco
Copy link
Member

bochaco commented Apr 30, 2019

@theWebalyst , regarding using browser local dev branch with safe_app_nodejs local master, I just tried this for mock and it worked (with node v10):
In safe_app_nodejs local master:
NODE_ENV=dev yarn && yarn link

Then on the browser local dev:
NODE_ENV=dev yarn && yarn link "@maidsafe/safe-node-app" && yarn rebuild && yarn mock-dev

@happybeing
Copy link
Author

Thanks @bochaco, I'll close this. If I need to come back to it I'll have another go, but maybe it will just work. Sorry if its been a wild goose chase.

@bochaco
Copy link
Member

bochaco commented Apr 30, 2019

As per the other issue about rdflib.js, from a theorical point of view, I cannot imagine why there could be a problem with an app includign such a lib wich is running as a webpage, with the rdflib.js that is used by the safe-app-nodejs in the backend as part of the browser. I'm not sure though, @joshuef would you expect any problem as described about this?

I just gave it a quick try running the demo app from here and I have no idea how that's supposed to work but I get the sites loading in the browser, and apart from some non-related errors I don't see anything else.

@happybeing
Copy link
Author

Yes, it may not be a general problem. It may be because solid-auth-client adds itself to window, and as that is done once by SB loading rdflib.js and then by the Web app doing so, which means there's a clash. I'm still investigating but keep having problems building/debugging. I had it all working once but can't get it back again atm 😦

Will update the other issue when I know something.

@calumcraig
Copy link

Just to check @calumcraig were you using yarn link safe-app-nodejs in safe_browser to use a local copy of safe_app_nodejs.

No, I wasn't which would tie in with the behaviour you are describing I think.

@happybeing
Copy link
Author

No, I wasn't which would tie in with the behaviour you are describing I think

Indeed. The problem I had was only when trying to yarn link safe-app-nodejs

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

No branches or pull requests

3 participants