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

Building a bundle for Browsers fails #72

Closed
paul90 opened this issue Dec 15, 2020 · 7 comments
Closed

Building a bundle for Browsers fails #72

paul90 opened this issue Dec 15, 2020 · 7 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@paul90
Copy link

paul90 commented Dec 15, 2020

Looks to be cause by a problem reported upstream as sodium-friends/sodium-universal#6

npm run build fails with:

❯ npm run build

> [email protected] build /Users/Paul/Projects/hyper/sdk
> cross-env BABEL_DISABLE_CACHE=1 browserify -t [ babelify --global ] --standalone hyperSDK index.js > hyper-sdk-bundle.js

Error: Can't walk dependency graph: Cannot find module './crypto_auth' from '/Users/Paul/Projects/hyper/sdk/node_modules/sodium-universal/index.js'
    required by /Users/Paul/Projects/hyper/sdk/node_modules/sodium-universal/index.js
    at /Users/Paul/Projects/hyper/sdk/node_modules/resolve/lib/async.js:137:35
    at load (/Users/Paul/Projects/hyper/sdk/node_modules/resolve/lib/async.js:156:43)
    at onex (/Users/Paul/Projects/hyper/sdk/node_modules/resolve/lib/async.js:181:17)
    at /Users/Paul/Projects/hyper/sdk/node_modules/resolve/lib/async.js:15:69
    at FSReqCallback.oncomplete (fs.js:183:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `cross-env BABEL_DISABLE_CACHE=1 browserify -t [ babelify --global ] --standalone hyperSDK index.js > hyper-sdk-bundle.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/Paul/.npm/_logs/2020-12-15T10_44_05_883Z-debug.log

Oh, and there is a missing npm install between cd sdk and npm run build in the readme.

@RangerMauve
Copy link
Owner

RangerMauve commented Dec 15, 2020

Thank you for looking into this, I haven't tested browser builds in a while.

Does pinning the version to 3.0.2 in the SDK's package.json help?

@RangerMauve RangerMauve added bug Something isn't working help wanted Extra attention is needed labels Dec 15, 2020
@paul90
Copy link
Author

paul90 commented Dec 16, 2020

Not sure, the browser build process works, but two of tests (51 and 52) fail with Firefox 83.0 (they all pass in Firefox 85.0b1 and Chrome).

Console Log: Click to expand
07:07:32.908 not ok 51 no error reading from core default_stream.js:25:26
07:07:32.908   --- default_stream.js:25:26
07:07:32.908     operator: error default_stream.js:25:26
07:07:32.908     expected: |- default_stream.js:25:26
07:07:32.908       undefined default_stream.js:25:26
07:07:32.908     actual: |- default_stream.js:25:26
07:07:32.908       { [Error: Block not available from peers] code: '', errno: 0, details: '' } default_stream.js:25:26
07:07:32.908     stack: |- default_stream.js:25:26
07:07:32.908       decode@http://localtest.me:3000/test-bundle.js:2619:17 default_stream.js:25:26
07:07:32.908       _onmessage@http://localtest.me:3000/test-bundle.js:8948:35 default_stream.js:25:26
07:07:32.908       _nextState@http://localtest.me:3000/test-bundle.js:9247:14 default_stream.js:25:26
07:07:32.908       _readMessage@http://localtest.me:3000/test-bundle.js:9166:19 default_stream.js:25:26
07:07:32.908       recv@http://localtest.me:3000/test-bundle.js:9145:44 default_stream.js:25:26
07:07:32.908       _write@http://localtest.me:3000/test-bundle.js:9011:22 default_stream.js:25:26
07:07:32.908       update@http://localtest.me:3000/test-bundle.js:93416:14 default_stream.js:25:26
07:07:32.908       updateWriteNT@http://localtest.me:3000/test-bundle.js:93745:6 default_stream.js:25:26
07:07:32.908       [435]</Item.prototype.run@http://localtest.me:3000/test-bundle.js:73204:12 default_stream.js:25:26
07:07:32.908       drainQueue@http://localtest.me:3000/test-bundle.js:73168:34 default_stream.js:25:26
07:07:32.908       setTimeout handler*runTimeout@http://localtest.me:3000/test-bundle.js:73080:12 default_stream.js:25:26
07:07:32.908       [435]</process.nextTick@http://localtest.me:3000/test-bundle.js:73193:15 default_stream.js:25:26
07:07:32.908       updateNextTick@http://localtest.me:3000/test-bundle.js:93622:13 default_stream.js:25:26
07:07:32.908       push@http://localtest.me:3000/test-bundle.js:93899:25 default_stream.js:25:26
07:07:32.908       WebSocketStream/this.socket.onmessage@http://localtest.me:3000/test-bundle.js:99513:41 default_stream.js:25:26
07:07:32.908       default_stream.js:25:26
07:07:32.908   ... default_stream.js:25:26
07:07:32.909 not ok 52 got data from replicated core default_stream.js:25:26
07:07:32.909   --- default_stream.js:25:26
07:07:32.909     operator: ok default_stream.js:25:26
07:07:32.909     expected: true default_stream.js:25:26
07:07:32.909     actual:   undefined default_stream.js:25:26
07:07:32.909     stack: |- default_stream.js:25:26
07:07:32.909       assert@http://localtest.me:3000/test-bundle.js:95094:50 default_stream.js:25:26
07:07:32.909       bound@http://localtest.me:3000/test-bundle.js:94928:22 default_stream.js:25:26
07:07:32.909       assert@http://localtest.me:3000/test-bundle.js:95205:8 default_stream.js:25:26
07:07:32.909       bound@http://localtest.me:3000/test-bundle.js:94928:22 default_stream.js:25:26
07:07:32.909       run/</</</<@http://localtest.me:3000/test-bundle.js:102814:13 default_stream.js:25:26
07:07:32.909       maybe/</<@http://localtest.me:3000/test-bundle.js:28930:11 default_stream.js:25:26
07:07:32.909       setTimeout handler*[126]</</</next<@http://localtest.me:3000/test-bundle.js:28919:13 default_stream.js:25:26
07:07:32.909       maybe/<@http://localtest.me:3000/test-bundle.js:28929:11 default_stream.js:25:26
07:07:32.909       promise callback*maybe@http://localtest.me:3000/test-bundle.js:28924:13 default_stream.js:25:26
07:07:32.909       get@http://localtest.me:3000/test-bundle.js:2265:10 default_stream.js:25:26
07:07:32.909       method@http://localtest.me:3000/test-bundle.js:1298:26 default_stream.js:25:26
07:07:32.909       run/</</<@http://localtest.me:3000/test-bundle.js:102812:15 default_stream.js:25:26
07:07:32.909       onceWrapper@http://localtest.me:3000/test-bundle.js:42433:30 default_stream.js:25:26
07:07:32.909       emitOne@http://localtest.me:3000/test-bundle.js:42260:21 default_stream.js:25:26
07:07:32.909       emit@http://localtest.me:3000/test-bundle.js:42328:14 default_stream.js:25:26
07:07:32.909       _onpeeropen@http://localtest.me:3000/test-bundle.js:2033:10 default_stream.js:25:26
07:07:32.909       onPeerOpen@http://localtest.me:3000/test-bundle.js:1542:20 default_stream.js:25:26
07:07:32.909       _onmessage@http://localtest.me:3000/test-bundle.js:8971:23 default_stream.js:25:26
07:07:32.909       _nextState@http://localtest.me:3000/test-bundle.js:9247:14 default_stream.js:25:26
07:07:32.909       _readMessage@http://localtest.me:3000/test-bundle.js:9166:19 default_stream.js:25:26
07:07:32.909       recv@http://localtest.me:3000/test-bundle.js:9145:44 default_stream.js:25:26
07:07:32.909       _write@http://localtest.me:3000/test-bundle.js:9011:22 default_stream.js:25:26
07:07:32.909       update@http://localtest.me:3000/test-bundle.js:93416:14 default_stream.js:25:26
07:07:32.909       updateWriteNT@http://localtest.me:3000/test-bundle.js:93745:6 default_stream.js:25:26
07:07:32.909       [435]</Item.prototype.run@http://localtest.me:3000/test-bundle.js:73204:12 default_stream.js:25:26
07:07:32.909       drainQueue@http://localtest.me:3000/test-bundle.js:73168:34 default_stream.js:25:26
07:07:32.909       setTimeout handler*runTimeout@http://localtest.me:3000/test-bundle.js:73080:12 default_stream.js:25:26
07:07:32.909       [435]</process.nextTick@http://localtest.me:3000/test-bundle.js:73193:15 default_stream.js:25:26
07:07:32.909       updateNextTick@http://localtest.me:3000/test-bundle.js:93622:13 default_stream.js:25:26
07:07:32.909       push@http://localtest.me:3000/test-bundle.js:93899:25 default_stream.js:25:26
07:07:32.909       WebSocketStream/this.socket.onmessage@http://localtest.me:3000/test-bundle.js:99513:41 default_stream.js:25:26
07:07:32.909       default_stream.js:25:26
07:07:32.909   ...

Also at the end of the console log there are 6 Uncaught (in promise) NRPC_ERR_CLOSE: nanomessage-rpc was closed errors.

@paul90
Copy link
Author

paul90 commented Dec 16, 2020

While typing my reply, above, I noticed that there was an incoming update to Firefox - retesting with this updated version Firefox 84.0 the tests all pass. So it looks as if pinning sodium-universal to 3.0.2 helps.

Not looked into all the changes that Firefox 84.0 brings. But, I do know that it corrects a long standing issue with the handling of localhost, adding support for localhost subdomains.

@RangerMauve
Copy link
Owner

Sweet, thank you for looking into this.

Would you be down to submit a pull request for pinning the version?

@paul90
Copy link
Author

paul90 commented Dec 17, 2020

Should be able to put together a PR.

paul90 added a commit to paul90/sdk that referenced this issue Dec 17, 2020
@paul90
Copy link
Author

paul90 commented Dec 17, 2020

Think I've found the underlying problem. The problem is with the sodium-universal 3.0.3 package not containing everything it should. It looks very much as if the prepublish didn't run!

If I clone the sodium-universal repo alongside the sdk repo, run npm i and then the run the prepublish script, then over in the sdk directory install sodium-universal from the local repo, using npm i $(npm pack ../sodium-universal | tail -1) the build for the browser works.

I'm going to close the PR.

@paul90
Copy link
Author

paul90 commented Feb 15, 2021

Closing this. The release of [email protected] has fixed this issue.

@paul90 paul90 closed this as completed Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants