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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update all configuration options in preparation for browser support #366

merged 17 commits into from Aug 20, 2019


Copy link

albrow commented Aug 16, 2019

This PR changes a variety of configuration options throughout the code in preparation for full browser support. It also introduces a functioning MVP example of Mesh running in the browser in the examples/ directory and enables seamless headless browser tests in CircleCI and as part of make test-all. This allows us to remove the more manual qunit-based tests from the meshdb package and just run all our tests normally.

The in-browser example currently comes with the following caveats:

  1. The only data that is stored permanently is the private key. This allows browser peers to retain the same Peer ID between refreshes, but all other data (orders, block headers, and peers) will be lost.
  2. Browser peers are undialable cannot connect directly to other browser peers. They can be connected to through a relay. However, they can dial any peer that supports the WebSockets transport.
  3. There is no JavaScript API for interacting with Mesh and therefore no way to add orders or receive order updates. The only way we can see what Mesh is doing is by looking at the logs.
  4. We still need to do some work to optimize performance and reduce bundle size. You might see your CPU usage spike while running the example.

To run the browser example yourself, you need a web server that supports the Wasm MIME type. An easy option is to install goexec. Then run the following commands from the root of the repository:

> GOOS=js GOARCH=wasm go build -o ./examples/browser/main.wasm ./examples/browser
> goexec 'http.ListenAndServe(":8000", http.FileServer(http.Dir("./examples/browser")))'

Finally visit http://localhost:8000 in your browser and open up the developer console to observe Mesh running 馃槃

@albrow albrow changed the title Create separate configuration options suitable for browser environments Update all configuration options in preparation for browser support Aug 16, 2019
@albrow albrow requested a review from fabioberger Aug 16, 2019
@albrow albrow added the browser label Aug 16, 2019
@albrow albrow added this to the Browser Support milestone Aug 16, 2019
@@ -1,3 +1,5 @@
// +build !browser

This comment has been minimized.

Copy link

albrow Aug 16, 2019

Author Member

This build tag means the test won't run in browser environments. It wouldn't work because we try to load a JSON file.

albrow added 14 commits Aug 15, 2019
@albrow albrow force-pushed the feature/config-for-browsers branch from 7d14e8e to 8b5a8df Aug 20, 2019
albrow added 3 commits Aug 20, 2019
@albrow albrow merged commit 86902ce into development Aug 20, 2019
1 check passed
1 check passed
ci/circleci: build Your tests passed on CircleCI!
@albrow albrow deleted the feature/config-for-browsers branch Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can鈥檛 perform that action at this time.