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

Support environments without MessageChannel or worker_threads #51

Closed

Conversation

RangerMauve
Copy link
Contributor

Part of #48

Fixes #47

This doesn't provide an alternative implementation for sodium_free, but it prevents runtime and compile-time errors in RN and node 10

@mafintosh
Copy link
Member

Don't have any issues with this. Will let @emilbayes get his thoughts in.

@RangerMauve
Copy link
Contributor Author

@emilbayes Regarding the convo on Discord, I haven't come across any equivalent memory freeing APIs in React-Native, sadly. It might be worth it to revisit once they have support for ArrayyBuffers in their bridging API (which is likely a long ways away).

@emilbayes
Copy link
Member

@RangerMauve I think I might have confused on discord, the intention here is just to make the underlying ArrayBuffer inaccessible, not exactly to free it :)

@RangerMauve
Copy link
Contributor Author

@emilbayes Yeah, I don't think RN provides anything special for that, sadly. 😅

Are there any APIs in ArrayBuffer itself that can make that work?
If there isn't would it be okay to leave it as is for the RN use case?

@emilbayes
Copy link
Member

Yeah there’s https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel but I guess RN doesn’t have that?

@RangerMauve
Copy link
Contributor Author

@emilbayes No, I don't think it does, sadly. It doesn't have support for workers or anything of the sort, doesn't have that as a global, and I don't think there are any built in modules which provide that functionality. 😅

@RangerMauve
Copy link
Contributor Author

RangerMauve commented Nov 1, 2020

@emilbayes Updated the PR per your comments so that memory gets zeroed even if it can't be freed.

You mentioned that you're not keen on merging due to the possiblity of "use after free" vulns. This wouldn't introduce them into Node.js or Browsers, and I think most of the libraries that'd be using this functionality would be targeting those environments too, and would reduce that risk.

This would enable the library to be used in React-Native and JS environments that are neither Node.js or web browsers, and while it's not ideal, I don't think there's any way to do memory freeing in React-Native at the moment.

I'd be happy to send a PR to add that in as soon as a way is found, but it would be nice to have even a non-ideal solution in the meantime. 😁

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.

worker_threads dependency breaks on Node 10
3 participants