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

App hangs on first run if run non-interactively #695

Closed
zuzak opened this issue Feb 25, 2019 · 2 comments
Closed

App hangs on first run if run non-interactively #695

zuzak opened this issue Feb 25, 2019 · 2 comments
Labels
Submitted by user issues on behalf of users

Comments

@zuzak
Copy link
Contributor

zuzak commented Feb 25, 2019

At the moment, if you run the prototype kit for the first time in an non-interactive way (say, as part of a Unix pipeline, or deployed into Kubernetes), the app will hang waiting for user input to opt into sharing usage data.

Perhaps we should default to "no" when this happens? For example:

diff --git a/lib/usage_data.js b/lib/usage_data.js
index 898e765..4083ce0 100755
--- a/lib/usage_data.js
+++ b/lib/usage_data.js
@@ -17,6 +17,7 @@ exports.getUsageDataConfig = function () {
   try {
     usageDataConfig = require(path.join(__dirname, '../usage-data-config.json'))
   } catch (e) {
+    if (!process.stdout.isTTY) return {'collectUsageData': false}
     // do nothing - we will make a config
   }
   return usageDataConfig
@NickColley
Copy link
Contributor

One alternative would be to remove the tracking if we find it has served it's purpose, for example there's nothing more we can learn.

@NickColley
Copy link
Contributor

@zuzak it seems sensible to default this to off if we know for sure the application is run by the user.

I think we would accept a pull request for what you've described here if it were also tested :)

Let me know if you need any help doing that. We can also pick this up when we get some time in the future.

zuzak added a commit to zuzak/govuk-prototype-kit that referenced this issue Feb 26, 2019
You can run the prototype toolkit in a way that does not accept input.
A basic example would be:

   $ npm start | cat

If this is the first time you have run the prototype kit, the
application will hang as there is no way to respond to the question
about recording usage data. This means it is difficult to run the
prototype kit solely without user input.

This commit changes the behaviour of that prompt to only appear if the
user is running the command in a TTY context.

If the user is not running the prototype kit in a TTY, the prompt will
be skipped and the default action will occur as if the user had simply
hit return. In this case, it'll default to "no" and opt the user out of
usage data collection automatically.

A downside of this approach is that the user will not get asked again
if they subsequently run the kit interactively. However, it is unlikely
that users will wish to run the prototype kit initially within a
pipeline whilst also wishing to run it interactively at a later date.

Closes alphagov#695. Another prompt occurs when the chosen port is in use, but
this commit doesn't attempt to edit that.
@kellylee-gds kellylee-gds added Submitted by user issues on behalf of users new and removed new labels Feb 27, 2019
NickColley pushed a commit to zuzak/govuk-prototype-kit that referenced this issue Mar 6, 2019
You can run the prototype toolkit in a way that does not accept input.
A basic example would be:

   $ npm start | cat

If this is the first time you have run the prototype kit, the
application will hang as there is no way to respond to the question
about recording usage data. This means it is difficult to run the
prototype kit solely without user input.

This commit changes the behaviour of that prompt to only appear if the
user is running the command in a TTY context.

If the user is not running the prototype kit in a TTY, the prompt will
be skipped and the default action will occur as if the user had simply
hit return. In this case, it'll default to "no" and opt the user out of
usage data collection automatically.

A downside of this approach is that the user will not get asked again
if they subsequently run the kit interactively. However, it is unlikely
that users will wish to run the prototype kit initially within a
pipeline whilst also wishing to run it interactively at a later date.

Closes alphagov#695. Another prompt occurs when the chosen port is in use, but
this commit doesn't attempt to edit that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Submitted by user issues on behalf of users
Projects
None yet
Development

No branches or pull requests

3 participants