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

TINKERPOP-2143 JavaScript GLV: Support browsers #1070

Closed
wants to merge 16 commits into from

Conversation

fdominik
Copy link

https://issues.apache.org/jira/browse/TINKERPOP-2143
Summary of changes:

  • Updated dependency on WS package (which was very old 3.0.0) to v 6.0.0. This is required by browsers.

  • Added dependency to util and events packages which were required by the javascript module, but were not listed in dependencies, so that it wouldn't compile.

  • Added new dependency to uiid library.

  • Generation of UUIDs was passed to UUID library instead of utilizing crypto package (which is not anymore available as separate library in browsers world, it is bundled, however some functions used in generating UUID were not available in the new bundled crypto). The uuid library can generate UUID of version 4, which was the version used to generate the UUIDs.

  • Usage of standard WebSocket object from default packages.

  • a new Buffer handling had to be written because the browser WS library doesnt have automatic creation of Buffer Arrays, so it had to be implemented from scratch => using Uint8Array.

Code has been tested in our UI project, where we can send requests from UI to Gremlin server. I wasn't able to run the Tinkerpop tests locally.

Dominik Franek and others added 16 commits January 24, 2019 22:45
* Change the way how random bytes are generated, not using the crypto package, but built-in Class.
* remove requiring the ws package
* update how WebSockets are called.
* Change the way how random bytes are generated, not using the crypto package, but built-in Class.
* remove requiring the ws package
* update how WebSockets are called.
* remove requiring the ws package
* update how WebSockets are called.

(cherry picked from commit b016cd1)
This reverts commit 0ba06a3 as it was unintentioanlly comitted to where PR will be created
@spmallette
Copy link
Contributor

@fdominik Travis seems to be complaining about something:

[INFO] --- frontend-maven-plugin:1.6:npm (npm test) @ gremlin-javascript ---
[INFO] Running 'npm test --exit' in /home/travis/build/apache/tinkerpop/gremlin-javascript/src/main/javascript/gremlin-javascript
[INFO] 
[INFO] > gremlin@3.4.1-alpha1 test /home/travis/build/apache/tinkerpop/gremlin-javascript/src/main/javascript/gremlin-javascript
[INFO] > mocha test/unit test/integration -t 5000
[INFO] 
[ERROR] module.js:471
[ERROR]     throw err;
[ERROR]     ^
[ERROR] 
[ERROR] Error: Cannot find module 'uuid/v4'
[ERROR]     at Function.Module._resolveFilename (module.js:469:15)
[ERROR]     at Function.Module._load (module.js:417:25)
[ERROR]     at Module.require (module.js:497:17)
[ERROR]     at require (internal/module.js:20:19)
[ERROR]     at Object.<anonymous> (/home/travis/build/apache/tinkerpop/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js:26:16)
[ERROR]     at Module._compile (module.js:570:32)
[ERROR]     at Object.Module._extensions..js (module.js:579:10)
[ERROR]     at Module.load (module.js:487:32)
[ERROR]     at tryModuleLoad (module.js:446:12)
[ERROR]     at Function.Module._load (module.js:438:3)
[ERROR]     at Module.require (module.js:497:17)
[ERROR]     at require (internal/module.js:20:19)
[ERROR]     at Object.<anonymous> (/home/travis/build/apache/tinkerpop/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js:25:15)
[ERROR]     at Module._compile (module.js:570:32)
[ERROR]     at Object.Module._extensions..js (module.js:579:10)
[ERROR]     at Module.load (module.js:487:32)
[ERROR]     at tryModuleLoad (module.js:446:12)
[ERROR]     at Function.Module._load (module.js:438:3)
[ERROR]     at Module.require (module.js:497:17)
[ERROR]     at require (internal/module.js:20:19)
[ERROR]     at Object.<anonymous> (/home/travis/build/apache/tinkerpop/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js:25:11)
[ERROR]     at Module._compile (module.js:570:32)
[ERROR]     at Object.Module._extensions..js (module.js:579:10)
[ERROR]     at Module.load (module.js:487:32)
[ERROR]     at tryModuleLoad (module.js:446:12)
[ERROR]     at Function.Module._load (module.js:438:3)
[ERROR]     at Module.require (module.js:497:17)
[ERROR]     at require (internal/module.js:20:19)
[ERROR]     at Object.<anonymous> (/home/travis/build/apache/tinkerpop/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/exports-test.js:26:19)
[ERROR]     at Module._compile (module.js:570:32)
[ERROR]     at Object.Module._extensions..js (module.js:579:10)
[ERROR]     at Module.load (module.js:487:32)
[ERROR]     at tryModuleLoad (module.js:446:12)
[ERROR]     at Function.Module._load (module.js:438:3)
[ERROR]     at Module.require (module.js:497:17)
[ERROR]     at require (internal/module.js:20:19)
[ERROR]     at /home/travis/build/apache/tinkerpop/gremlin-javascript/src/main/javascript/gremlin-javascript/node_modules/mocha/lib/mocha.js:231:27
[ERROR]     at Array.forEach (native)
[ERROR]     at Mocha.loadFiles (/home/travis/build/apache/tinkerpop/gremlin-javascript/src/main/javascript/gremlin-javascript/node_modules/mocha/lib/mocha.js:228:14)
[ERROR]     at Mocha.run (/home/travis/build/apache/tinkerpop/gremlin-javascript/src/main/javascript/gremlin-javascript/node_modules/mocha/lib/mocha.js:514:10)
[ERROR]     at Object.<anonymous> (/home/travis/build/apache/tinkerpop/gremlin-javascript/src/main/javascript/gremlin-javascript/node_modules/mocha/bin/_mocha:484:18)
[ERROR]     at Module._compile (module.js:570:32)
[ERROR]     at Object.Module._extensions..js (module.js:579:10)
[ERROR]     at Module.load (module.js:487:32)
[ERROR]     at tryModuleLoad (module.js:446:12)
[ERROR]     at Function.Module._load (module.js:438:3)
[ERROR]     at Module.runMain (module.js:604:10)
[ERROR]     at run (bootstrap_node.js:383:7)
[ERROR]     at startup (bootstrap_node.js:149:9)
[ERROR]     at bootstrap_node.js:496:3
[ERROR] npm ERR! Test failed.  See above for more details.

Failed on two separate builds which is interesting because I wasn't aware javascript builds were running twice. @jorgebay it seems like we don't use the .glv file to control whether or not gremlin-javascript builds. I think that's fine given that the maven plugin seems to handle all the environmental setup on the local machine. Any reason we need a specific build for gremlin-javascript then? seems like we could just rely on the regular mvn clean install build, right?

@fdominik
Copy link
Author

fdominik commented Feb 25, 2019

@spmallette yeah I've noticed that, I tried to solve, it didn't help. And I hoped somebody could direct me, why the dependencies are not read from package.json file. Because the reason it fails is that Travis can't find the uuid library I added to dependencies. I will try to investigate the issue and come with solution, but it might take some time as I am on vacation now and doing it when it is rainy :)

@spmallette
Copy link
Contributor

@fdominik - sorry it took me some time to come back to this. if the problem is with package.json then i think it's likely that your problem is related to the fact that we generate package.json from:

https://github.com/apache/tinkerpop/blob/3c87b3a99b5182b9c1dc245d474def1662bae68f/gremlin-javascript/glv/PackageJson.template

That generation is triggered by a maven command so that's probably why maven builds in Travis are having trouble. Hopefully, that solves your problem.

As far as other issues go, I'll largely defer to @jorgebay and @jbmusso but I think that administratively, it would be nice to have an entry added in CHANGELOG for 3.4.1:

https://github.com/apache/tinkerpop/blob/3c87b3a99b5182b9c1dc245d474def1662bae68f/CHANGELOG.asciidoc

and if you want to really polish this up, then you would want to add a section to our "Upgrade Documentation":

https://github.com/apache/tinkerpop/blob/3c87b3a99b5182b9c1dc245d474def1662bae68f/docs/src/upgrade/release-3.4.x.asciidoc

specifically, a subsection to an "Upgrading for Users" for 3.4.1. This change seems interesting enough that users would want to know about it.

anyway, let's see if your build problem gets resolved on Travis and then we can resume the review process.

@spmallette
Copy link
Contributor

@fdominik we are preparing for our next official release in the next couple of weeks or so - I just wanted to let you know what the release schedule was looking like in case you intended to return to this PR.

@fdominik
Copy link
Author

fdominik commented May 6, 2019

@spmallette Thanks Stephen, I just returned today after several weeks of being out. So I might get into the PR this week I hope.

@shanequint
Copy link

What's the status on this? I would be very interested in this browser based approach. Any idea when/if this will be incorporated?

@spmallette
Copy link
Contributor

As a quick update from my perspective....My comments on this issue from 2/28 still stand I think. If those items get done I think this one would be ready for review. I would add that at this point this PR should probably be rebased on tp34 branch as master is now for 3.5.0. We are currently starting the release process for 3.4.3 so this PR is probably headed for 3.4.4 or later at this point. Thanks for inquiring @shanequint

@x007007007
Copy link

hi, I try to checkout your pr and run local, I have a error once I have a query like g.V().valueMap(true).toList()

TypeError: this._ws.removeAllListeners is not a function[详细了解] app.js line 5320 > eval:309:5
_cleanupWebsocket
connection.js:309
_handleClose
connection.js:224
open/this._ws.onclose
connection.js:125

@dgyates
Copy link

dgyates commented Feb 6, 2020

Is there anyone else still working/looking at this? We're using @fdominik 's branch -- which is significantly behind version wise?

Browser support would be amazing to my team's work

@spmallette
Copy link
Contributor

hi @dgyates - my previous comments are not yet addressed. If you'd like to pick up from where @fdominik left off and polish this up for a final review by @jorgebay I think we could get this sorted out for next release.

@fdominik
Copy link
Author

fdominik commented Feb 7, 2020

Hi @dgyates I am sorry, I am probably not able to finish it as I don't know how to prepare the travis environment localy and run the failing tests. I am sure that somebody more skilled in JS would be able to resolve such issue in a manner of hous.

@jbmusso
Copy link
Contributor

jbmusso commented Mar 18, 2020

Jumping back in, I'd be happy to help if I can.

@spmallette
Copy link
Contributor

@jbmusso it would be great if you could help get this one to completion. at this point i'd suggest pulling the commits in this PR to a TINKERPOP-2143 branch and establishing a fresh PR from there at which point we can close this one.

@spmallette
Copy link
Contributor

Closing in favor of #1291 where changes have been pulled in, squashed and rebased on master to get rid of conflicts and merge commits. The same basic issues remain with this one.

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

Successfully merging this pull request may close these issues.

6 participants