Fix spawn_on_env vars leaking from server to app #749
Merged
+16
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, variables specified by
spawn_on_envwould behave inconsistently when the Spring server was created with one of those variables set:would cause future clients' apps to be booted with
VAR_FROM_BOOT=beforeset, even if the client is created without that variable:and additionally, Spring would hide that the app was booted with that var set by unsetting it when the client attached to its app (making it look like the correct ENV).
The issue was caused by how
spawn_on_envwas passed from client to server to app:spawn_on_envkeys from itsENV, meaningbin/rails ...would have an emptyspawn_on_envhash.VAR_FROM_BOOTset), forks an app withspawn_on_envvalues set (none, because its an empty hash)ENV, so it boots withVAR_FROM_BOOTsetThis is specifically an issue for
spawn_on_envbecause the goal is to have apps booted with different environments.This commit fixes the issue by always passing all
Spring.spawn_on_envvalues from the client to the server (includingnilones) so that the forked app will have those values cleared if necessary.compactis added to theSPRING_SPAWN_ENVvalue because it is only used to display thespawn_on_envvalues inspring statusand showing all of thenilvalues is noisy/unnecessary.