Giter Club home page Giter Club logo

Comments (36)

shumkov avatar shumkov commented on August 23, 2024 1

Pure JS implementation is ready to use https://github.com/grpc/grpc-node/releases/tag/%40grpc%2Fgrpc-js%401.0.0

from platform.

shumkov avatar shumkov commented on August 23, 2024 1

In v0.21 we migrated to the pure JS implementation of the gRPC library, so you can use this version for your test.

from platform.

SamKirby22 avatar SamKirby22 commented on August 23, 2024 1

Discussed in Triage - Merged and ready for retest in v21.

from platform.

shumkov avatar shumkov commented on August 23, 2024 1

Interesting. @jawid-h @dash-maverick shall we just release your branch as NPM module in dashevo organisation?

from platform.

jawid-h avatar jawid-h commented on August 23, 2024 1

@shumkov it is not, let's release our version maybe. I would merge latest updates from v6 of the original repo as well

from platform.

dash-maverick avatar dash-maverick commented on August 23, 2024 1

Hey. The investigation/fix is being currently in progress. You can expect some updates here quite soon.

from platform.

pshenmic avatar pshenmic commented on August 23, 2024 1

Hey guys. Just checked it out and what I found. :)

The reason why it is not working on RunKit is that they have 6.10 protobufjs package, but our package depedency is set to 6.10.5, but only 6.5.1 is available on the RunKit. So, we have two options: we can wait until RunKit will update their protobufjs package to corresponding version, or downgrade to a previous version which is available everywhere.

AWS Lambdas is working fine. Though I needed to bundle Dash SDK in zip first. The reason is that AWS Lambda does not have any internal package manager, so you have to prepare dependencies by yourself. I installed dash package in the separate directory and put everything in the .zip file.

https://stackoverflow.com/questions/34437900/how-to-load-npm-modules-in-aws-lambda

After uploading it on my AWS, I have been able to retrieve most recent blockhash via this Lambda code:

const Dash = require('dash')

exports.handler = async (event) => {
  const client = new Dash.Client();

  const blockHash = await client.getDAPIClient().core.getBestBlockHash();

  await client.disconnect()

  const response = {
    statusCode: 200,
    body: JSON.stringify('The hash: ' + blockHash),
  };

  return response;
}

image

from platform.

shumkov avatar shumkov commented on August 23, 2024 1

@pshenmic good catch! @thephez shall we update documentation. Maybe we need something like "troubleshooting" section there?

from platform.

dashameter avatar dashameter commented on August 23, 2024 1

I retested it on codepen with this snippet:

<html>
  <head>
    <title>Load NPM package in browser</title>
    <script
      crossorigin src='https://unpkg.com/[email protected]/dist/dash.min.js'
    ></script>
  </head>

  <body>
    <script>
   async function main () {
   console.log('main')
   const client = new Dash.Client();
   console.log('client')
   
   const blockHash = await client.getDAPIClient().core.getBestBlockHash();
   console.log("blockhash")
   console.log(blockHash)

   const response = {
    statusCode: 200,
    body: JSON.stringify('The hash: ' + blockHash),
  };
   await client.disconnect()

   return response;
}
main()
    </script>
  </body>
</html>

and get a network error. This bug describes as expected behavior: Expected to be able to use DashJS without issue, regardless of platform.

So I like to keep this bug open until Dash can be confidently used on a variety of platforms without hiccup.

from platform.

Alex-Werner avatar Alex-Werner commented on August 23, 2024

Thank you so much !
I wonder if not committing package-lock.json be enough ?
Did you try with default script but with the lock file removed ?

Mentioning @antouhou @shumkov too, they might be interested.

from platform.

thephez avatar thephez commented on August 23, 2024

Thanks for the info. I have bumped into this when using repl.it (e.g. name script) recently, but thought it was something related to changes on their site and did not debug any further.

from platform.

shumkov avatar shumkov commented on August 23, 2024

@riongull Thank you very much for your report and the provided solution. It seems like we need to compile it manually for rare platforms. I think it's fair for everything.

I'm afraid, we can't add this post-install script 'coz it's too specific (not universal).

@Alex-Werner Removing package-lock.json is not a case. We won't be able to guarantee that things are works properly with different deps.

What if we just document this solution and ask people to solve it manually?

P.S. We could use pure JS implementation when it ready https://github.com/grpc/grpc-node/tree/master/packages/grpc-js

from platform.

riongull avatar riongull commented on August 23, 2024

Happy to help, men. @shumkov, I think it would be good to look into whether the pure JS implementation will work for us. It seems to have pretty good feature parity.

from platform.

thephez avatar thephez commented on August 23, 2024

@Alex-Werner @shumkov Can we switch to this solution soon? Would be nice to get this issue closed.

from platform.

shumkov avatar shumkov commented on August 23, 2024

Yeah, but we need to ask @dalibran about priority.

from platform.

riongull avatar riongull commented on August 23, 2024

In terms of priority, this issue is no longer blocking me (or anyone else who reads this for the solution). Issue dashevo/js-dash-sdk#46 on the other hand is blocking anyone who wants to consume DashJS in a typescript file. Solving that first would not only unblock them, it should also provide IntelliSense to normal JS devs so that they can see documentation in their IDE, which lowers the urgency of keeping text docs up to date.

from platform.

cloudwheels avatar cloudwheels commented on August 23, 2024

Longshot as there's no direct error message, but might this also explain why dash can't be used in runkit, which gives the error Cannot find module 'grpc' ... in @dashevo/dapi-grpc/clients/nodejs/CorePromiseClient.js ?
( https://npm.runkit.com/dashand and run to recreate)

Pure js version might at least solve that problem too since https://npm.runkit.com/@grpc/grpc-js is a thing, whereas https://npm.runkit.com/grpc does indeed show it as missing.

from platform.

cloudwheels avatar cloudwheels commented on August 23, 2024

@shumkov Is it possible to clarify whether the additional considerations for migration below are likely to exist, or whether this should be 'a drop-in replacement'?

Migrating from grpc
@grpc/grpc-js is almost a drop-in replacement for grpc, but you may need to make a few code changes to use it:

If you are currently loading .proto files using grpc.load, that function is not available in this library. You should instead load your .proto files using @grpc/proto-loader and load the resulting package definition objects into @grpc/grpc-js using grpc.loadPackageDefinition.

If you are currently loading packages generated by grpc-tools, you should instead generate your files using the --generate_package_definitions option in grpc-tools, then load the object exported by the generated file into @grpc/grpc-js using grpc.loadPackageDefinition.

If you have a server and you are using Server#bind to bind ports, you will need to use Server#bindAsync instead.

from platform.

shumkov avatar shumkov commented on August 23, 2024

@cloudwheels yeah, we already use proto-loader, so It should be easy. Please check https://github.com/dashevo/dapi-grpc

P.S. Your PR as usual will be appreciated 😉

from platform.

dashameter avatar dashameter commented on August 23, 2024

@cloudwheels @riongull have you had success running the pure js implementation on aws or is there additional work required that we could bounty out to the incubator?

from platform.

dashameter avatar dashameter commented on August 23, 2024

Testing pure js implementation:

using sdk on runkit: https://runkit.com/embed/4hfnp3oa7eki

throws: Error: Cannot find module 'protobufjs' even though protobufjs is on runkit: https://npm.runkit.com/protobufjs

from platform.

SamKirby22 avatar SamKirby22 commented on August 23, 2024

Thanks @dashameter i've marked this as Failed Retest on the triage sheet.

from platform.

thephez avatar thephez commented on August 23, 2024

@dashameter It's probably related to dapi-grpc (see https://npm.runkit.com/@dashevo/dapi-grpc) which uses this: https://github.com/dashevo/dapi-grpc/blob/v0.22-dev/package-lock.json#L16. I frequently have issues due to a git+ssh reference in package-lock.json for this specific dependency (which I've gotten around by borrowing this).

from platform.

SamKirby22 avatar SamKirby22 commented on August 23, 2024

@dashameter please verify workaround. Thanks

from platform.

dashameter avatar dashameter commented on August 23, 2024

@dashameter It's probably related to dapi-grpc (see https://npm.runkit.com/@dashevo/dapi-grpc) which uses this: https://github.com/dashevo/dapi-grpc/blob/v0.22-dev/package-lock.json#L16. I frequently have issues due to a git+ssh reference in package-lock.json for this specific dependency (which I've gotten around by borrowing this).

Thanks for the trick, how would I use git config --global url."https://github.com/".insteadOf ssh://[email protected]/ with runkit, though ? The whole issue to be resolved is being able to use the sdk with js only, e.g. runkit or aws lambda functions.

from platform.

dash-maverick avatar dash-maverick commented on August 23, 2024

@thephez can you refer to that please ?

from platform.

thephez avatar thephez commented on August 23, 2024

@dash-maverick I was using the library in a different way and the workaround I used isn't applicable for this case. Someone else (probably a dev) will need to look at this. It appears this is still an issue with the latest dev version (0.22-dev.7).

from platform.

thephez avatar thephez commented on August 23, 2024

@shumkov Some interesting discussion in a GH issue that appears related: npm/cli#2610 (comment). Perhaps updating this would fix it: https://github.com/dashevo/platform/blob/v0.22-dev/packages/dapi-grpc/package.json#L41? And https://github.com/dashevo/platform/blob/v0.22-dev/packages/js-grpc-common/package.json#L34 and https://github.com/dashevo/platform/blob/v0.22-dev/package.json#L68?

from platform.

jawid-h avatar jawid-h commented on August 23, 2024

@shumkov yeah, probably we should, let me check if a 7 version is released

from platform.

dashameter avatar dashameter commented on August 23, 2024

image
retest failed with sdk v3.21.8

from platform.

dash-maverick avatar dash-maverick commented on August 23, 2024

try it out with v22 please

from platform.

dashameter avatar dashameter commented on August 23, 2024

retest failed on v22.1

https://runkit.com/622b3b64e1ba8c000a6090da/62403edffa69e900094bb6ee

image

from platform.

SamKirby22 avatar SamKirby22 commented on August 23, 2024

As per triage, unable to reproduce, please retest.

from platform.

dashameter avatar dashameter commented on August 23, 2024

retest was requested in discord by @SamKirby22

with v22.7 it still fails:

image

from platform.

dashameter avatar dashameter commented on August 23, 2024

If we can downgrade so it runs on Runkit that would be a good idea.

from platform.

SamKirby22 avatar SamKirby22 commented on August 23, 2024

@riongull can you take a quick look at the fix for this and let us know if it's fixed (for your specific use case)?

from platform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.