Skip to content

Refactoring to use ws napi modules #302

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

Closed
wants to merge 1 commit into from

Conversation

andreek
Copy link
Contributor

@andreek andreek commented Dec 4, 2017

  • removed native modules
  • change imports
  • add napi dependencies for native modules

Should probably be merged into a n-api branch.

#284

@andreek andreek changed the title Refactoring to use napi modules Refactoring to use ws napi modules Dec 4, 2017
@andreek andreek force-pushed the master branch 2 times, most recently from 275f888 to 9f5dda7 Compare December 7, 2017 14:05
@theturtle32
Copy link
Owner

@ibc - What do you think about going with this approach instead of continuing to include and maintain native modules directly?

@ibc
Copy link
Collaborator

ibc commented Dec 9, 2019

Definitely it looks good, less to maintain.

  - removed native modules
  - change imports
  - add napi dependencies for native modules
@alcuadrado
Copy link

Hey @theturtle32 are you interested in external contributors's help on making a N-API version of this package?

@theturtle32
Copy link
Owner

theturtle32 commented Jun 29, 2020 via email

@alcuadrado
Copy link

That's great! Me or @nebojsa94 will take a look at this and help to migrate this to n-api

@ibc
Copy link
Collaborator

ibc commented Jun 29, 2020

Also take this into account: #302

@theturtle32
Copy link
Owner

@nebojsa94 or @alcuadrado - Is this existing pull request viable? Could it be used as a starting point?

@alcuadrado
Copy link

@theturtle32 I'm on it right now. It looks viable at first look. Have the native modules in here been modified? Or are they just vendored versions of ws's?

@andreek
Copy link
Contributor Author

andreek commented Jun 30, 2020

I was never confident if it's ok to remove the fallbacks. I assumed they're used if build of native modules goes wrong.

@alcuadrado as far as I remember the native modules were not available as separated packages from ws. So I guess the code was ported out of ws before the npm packages bufferutil and utf-8-validate were available.

@alcuadrado
Copy link

I was never confident if it's ok to remove the fallbacks. I assumed they're used if build of native modules goes wrong.

IMO N-API based modules always need fallbacks, as people may run them on operating systems or architectures that don't have prebuilt binaries. For example, most don't have ARM binaries.

Both bufferutil and utf-8-validate and have fallbacks :)

Have the native modules in here been modified? Or are they just vendored versions of ws's?

I checked this and both the local and the npm versions of these packages expose the same functions, so they should be a linear replacement.

@theturtle32 I think this PR is all that's needed to move this package to N-API. The only thing that may need some consideration is if the change in package.json's engines deserves a major version bump.

Note that GitHub shows @andreek's master's last commit being from 2017, but it's actually up to date with this repo.

@nebojsa94
Copy link
Contributor

This looks good,

@theturtle32 Do you think that changes in package.json require major version bump?

@alcuadrado
Copy link

Hey @theturtle32, sorry to bother you again. Is there anything we can do to help move this forward?

This is change is pretty important to us, as we are currently working with multiple projects to move the node-based Ethereum ecosystem into N-API based dependencies, and one of our core libraries depends on websocket.

One of the main reasons we are doing this is that non N-API native libraries require a somewhat particular setup, especially on windows. This setup can be tricky, slow, and normally requires downloading gigabytes of data, making it a blocker for many new developers. This is a recurrent issue in workshops and other educational contexts, where time and bandwidth constraints make setting up the environment almost impossible.

While we are moving forward with this effort in other libraries, and are close to moving most to N-API, a single one requiring this setup can spoil our efforts. We could move from websocket into another library if you don't agree with using the N-API libraries, but that doesn't seem to be the case.

Thanks!

@andreek
Copy link
Contributor Author

andreek commented Jul 9, 2020

@theturtle32 I think this PR is all that's needed to move this package to N-API. The only thing that may need some consideration is if the change in package.json's engines deserves a major version bump.

Considering the fallbacks in bufferutil and utf-8-validate it's might be not necessary to update engines in package.json. I changed this because N-API is not further back ported. But actually bufferutil and utf-8-validate do not require any engine.

@theturtle32
Copy link
Owner

theturtle32 commented Jul 13, 2020 via email

@alcuadrado
Copy link

Thanks for the reply, Brian. Hope you had a great time.

I tried running the tests in node 0.10.x, to understand if a major version bump was needed, but I failed to install the project. I got an HTTPS error that I tried to workaround, but I couldn't.

@alcuadrado
Copy link

Hey @theturtle32, any updates on this?

@theturtle32
Copy link
Owner

@alcuadrado Looks good. Will merge.

@theturtle32
Copy link
Owner

Well, I'll test first, and then merge.

@nebojsa94
Copy link
Contributor

Hey @theturtle32, hope you're doing well!

I've forked @andreek fork and added GitHub actions workflow for testing, you can check out the results here: https://github.com/Tenderly/WebSocket-Node/pull/1/checks?check_run_id=958210778.

Is there anything else on our side we can do to help you get this upstream?

@theturtle32
Copy link
Owner

Incorporated into #394

@theturtle32
Copy link
Owner

@andreek @ibc @nebojsa94 - This has been published on npm as v1.0.32

@GregTheGreek
Copy link

@theturtle32 do you mind tagging the commit on github :)

@theturtle32
Copy link
Owner

@theturtle32 do you mind tagging the commit on github :)

Done.

@GregTheGreek
Copy link

Thanks so much ! 👍

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