8000 Fix for running in electron environment by mkramb · Pull Request #59 · kubernetes-client/javascript · GitHub
[go: up one dir, main page]

Skip to content

Fix for running in electron environment #59

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

Conversation

mkramb
Copy link
@mkramb mkramb commented Jul 12, 2018

I'm using kubernetes-client in electron environment (in main/node renderer) and the underlying library shelljs has issues when running as an electron package application. More information here:

Based on testing the cleanest solution is setting exec to async mode, which doesn't have this problem. I'm using this in https://github.com/mkramb/jx-tray which is a start of https://jenkins-x.io desktop client.

No changes in functionality & existing tests are passing.

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 12, 2018
@mkramb mkramb changed the title fix running shelljs as asynch operation Fix for running in electron environment Jul 12, 2018
@brendandburns
Copy link
Contributor

@mkramb we need you to sign the CNCF CLA.

Thanks!

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jul 14, 2018
@brendandburns
Copy link
Contributor

@mkramb does this actually work? This is changing the call from being synchronous to being asynchronous and I worry that there is a race between token update and web request generation...

(separately I'm having similar issues for the Azure provider, so we do need to deal with async clients somehow here...)

@mkramb
Copy link
Author
mkramb commented Jul 26, 2018

I have signed CLA.

It works (tested in electron environment) and also existing tests are passing, also the attached issue - if you look at the last comment from the ShellJS maintainer, it looks like best solution ATM.

shelljs/shelljs#480

@brendandburns
Copy link
Contributor

This needs a rebase.

I still am not confident that this will work correctly given that it is switching the call from sync to async, it feels racy to me... (and I'm not positive the tests cover that particular part of the code, sorry!)

Any chance that you can conditionalize this so that it only works this way when running in electron?

Thanks!

@itowlson
Copy link
Contributor
itowlson commented Oct 2, 2018

Would a safe way forward on this be to create async versions of the applyToHTTPSOptions and applyToRequest functions, and call the async version of shelljs.exec only from within those async forms? Then Electron apps could call the applyToHTTPSOptionsAsync and applyToRequestAsync methods, while vanilla Node applications could call either the sync or async methods.

Most places within the code that call applyToHTTPSOptions or applyToRequest seem to be returning Promises, so could call the async versions.

It would be a much larger piece of work though (and not lacking in risk either).

@edvald
Copy link
Contributor
edvald commented Oct 20, 2018

This doesn't actually work, it just swallows the error because the function returns immediately, and doesn't have an error event handler. I would suggest switching from shelljs to https://github.com/sindresorhus/execa instead (and making the enclosing function async along the way), since none of the other features of shelljs are being used. I can make a quick PR for that if you'd like.

@mkramb mkramb closed this Oct 20, 2018
@edvald edvald mentioned this pull request Oct 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0