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

Fix / Forward native ENV variables to child process #129

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

gwleuverink
Copy link
Contributor

@gwleuverink gwleuverink commented Nov 12, 2024

This PR applies the fix as suggested in NativePHP/laravel#402 on the electron plugin side.

This way we don't need to forward any variables from the process facade. This also is more in line with how internal processes are handled (like the queue & the php server)

Mind that the native env variables are forwarded to every child process. Not exclusively to artisan commands. This was touched on in PR NativePHP/laravel#402. We could do a separate endpoint for artisan commands, though I'm doubting now we know it concerns a small amount of extra variables. There is no harm (I can think of) in passing them along.

@gwleuverink gwleuverink changed the title Fix | Forward native ENV variables to child process Fix / Forward native ENV variables to child process Nov 12, 2024
Copy link
Member

@simonhamp simonhamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this

As it's done in the startProcess method tho (i.e. applies to every child process started this way), I'm still a little concerned that we'll essentially be "leaking" environment variables to whatever process the developer runs.

Whilst I think they're generally well-named environment variables, there's a risk that they may be used incorrectly or even abused... so I'm inclined to suggest that we don't do this by default for everything and instead have either an explicit method for this or an opt-in flag

@SRWieZ
Copy link
Contributor

SRWieZ commented Nov 13, 2024

I agree about env variable that should be passed only to php/artisan processes.

I also think it's important we send the ini configuration to php processes.

That's why I suggested a php endpoint in the first place.

@gwleuverink
Copy link
Contributor Author

I agree about env variable that should be passed only to php/artisan processes.

I also think it's important we send the ini configuration to php processes.

That's why I suggested a php endpoint in the first place.

Okay! I'll convert this to draft. I was hacking on this before seeing the conclusion of the other PR 😅 Like a real life race condition

To verify I fully comprehend what we're trying to achieve let me recap.

  1. Add php endpoint that starts a process with php_ini config & getDefaultEnvironmentVariables
  2. Make the artisan endpoint use the php endpoint internally
  3. Bonus: Tidy up startQueueWorker to use getDefaultEnvironmentVariables

On the Laravel side:

  1. Point the ChildProcess calls to the new endpoint
  2. Update tests

Do I have the right idea? I'm wondering if we need two endpoints in that case or just the one? PHP that only passes ini settings & artisan that passes the native env variables & ini settings.

@gwleuverink gwleuverink marked this pull request as draft November 13, 2024 08:38
@gwleuverink
Copy link
Contributor Author

gwleuverink commented Nov 13, 2024

Also @SRWieZ if you like to pick up any of this feel free. Didn't mean to swoop in. Only if you want to of course, no pressure 🤝

@simonhamp
Copy link
Member

Do I have the right idea?

Sounds like it to me

@SRWieZ
Copy link
Contributor

SRWieZ commented Nov 13, 2024

Also @SRWieZ if you like to pick up any of this feel free. Didn't mean to swoop in. Only if you want to of course, no pressure 🤝

No worries! 😌 Already gave my input. You can take it from there. I will be less available for 2 days so fill free to finish this.

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.

3 participants