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

cordova@8.1.0 breaks when prompting for telemetry opt-in #337

Closed
rhysburnie opened this Issue Sep 27, 2018 · 10 comments

Comments

Projects
None yet
5 participants
@rhysburnie
Copy link

commented Sep 27, 2018

Hi,

After installing npm install -g cordova no cordova commands work at all
Every command asks if you can track, answering yes or no make no difference
Ticks around a while then reports the following error
Tried reinstall, uninstall / reinstall
No luck

Cant check version because that too results in error - but I just ran normal install command

/Users/rgb/.nvm/versions/node/v8.9.4/lib/node_modules/cordova/node_modules/insight/lib/index.js:156
		prompt.close();
		       ^

TypeError: prompt.close is not a function
    at Insight.<anonymous> (/Users/rgb/.nvm/versions/node/v8.9.4/lib/node_modules/cordova/node_modules/insight/lib/index.js:156:10)
    at ontimeout (timers.js:475:11)
    at tryOnTimeout (timers.js:310:5)
    at Timer.listOnTimeout (timers.js:270:5)

Also tried globally installing an npm module called prompt incase that was the issue - no luck

@project-bot project-bot bot added this to 🐣 New PR / Untriaged in Apache Cordova: Tooling Pull Requests Sep 27, 2018

@rhysburnie

This comment has been minimized.

Copy link
Author

commented Sep 27, 2018

Looking at that file:

var permissionTimeout;

        var prompt = inquirer.prompt({
                type: 'confirm',
                name: 'optIn',
                message: msg || defaultMsg,
                default: true
        }, function (result) {
                // clear the permission timeout upon getting an answer
                clearTimeout(permissionTimeout);

                this.optOut = !result.optIn;
                cb(null, result.optIn);
        }.bind(this));

        // add a 30 sec timeout before giving up on getting an answer
        permissionTimeout = setTimeout(function () {
                // stop listening for stdin
                prompt.close();

Two things:

  1. I gave answer well within 30sec timeout so why would it even call that
  2. Either inquirer.prompt does not have .close() or there should be one added to the returned object?
@rhysburnie

This comment has been minimized.

Copy link
Author

commented Sep 27, 2018

OK found the issue will send pr

@rhysburnie

This comment has been minimized.

Copy link
Author

commented Sep 27, 2018

OK FYI the bug is already fixed in the latest on insight package - so you just need to update version

The current insight version being used in cordova 8.1.0 uses a callback mechanism for the inquirer package - that package now has a promise based interface.

@rhysburnie rhysburnie changed the title no cordova command work no cordova command work - see last comment for fix Sep 27, 2018

@brodybits

This comment has been minimized.

Copy link
Contributor

commented Sep 27, 2018

Can you please share the following information:

  • which platform
  • output of node --version
  • output of npm --version

I just tried Cordova CLI 8.1.0 on Node.js 4, 6, 8, and 10 on my Windows PC. I found issue on Node.js 4 and raised issue #339; cordova --version on Cordova CLI 8.1.0 works fine for me on Node.js 6, 8, and 10.

Possibly related: #338

@shazron

This comment has been minimized.

Copy link
Contributor

commented Sep 27, 2018

I found a repro for this bug on node 8.12.0, npm 6.4.1

@raphinesse

This comment has been minimized.

Copy link
Contributor

commented Sep 27, 2018

I guess the important part here is that you must not have a saved opt-in for this issue to surface.

@brodybits In hindsight, we should have tested the use-case that actually uses inquirer after fiddling with the transitive dependencies. I guess a release with older inquirer should work.

@raphinesse raphinesse changed the title no cordova command work - see last comment for fix cordova@8.1.0 breaks when prompting for telemetry opt-in Sep 27, 2018

@raphinesse raphinesse added the bug label Sep 27, 2018

@raphinesse

This comment has been minimized.

Copy link
Contributor

commented Sep 27, 2018

As I said before, this error only occurs when you have not answered the telemetry prompt before. Thus, a valid work-around would be to add "optOut": false or "optOut": true to ~/.config/configstore/insight-cordova.json. I don't know where the file is located on Windows, unfortunately.

@janpio

This comment has been minimized.

Copy link
Contributor

commented Sep 27, 2018

For Windows it should be in C:\Users\%USERNAME%\.config\configstore\insight-cordova.json

raphinesse added a commit to raphinesse/cordova-cli that referenced this issue Sep 27, 2018

Revert messing with transitive dependencies
This re-introduces a _low-severity_ `npm audit` warning.

Fixes apache#337
@brodybits

This comment has been minimized.

Copy link
Contributor

commented Sep 27, 2018

I just reproduced this issue on Windows:

C:\Users\brodybits\Documents
λ rm -rf \Users\brodybits\.config\

C:\Users\brodybits\Documents
λ cordova --version
? May Cordova anonymously report usage statistics to improve the tool over time? Yes
C:\Users\brodybits\AppData\Local\nvs\node\10.11.0\x64\node_modules\cordova\node_modules\insight\lib\index.js:156
                prompt.close();
                       ^

TypeError: prompt.close is not a function
    at Insight.<anonymous> (C:\Users\brodybits\AppData\Local\nvs\node\10.11.0\x64\node_modules\cordova\node_modules\insight\lib\index.js:156:10)
    at ontimeout (timers.js:425:11)
    at tryOnTimeout (timers.js:289:5)
    at listOnTimeout (timers.js:252:5)
    at Timer.processTimers (timers.js:212:10)

@janpio janpio removed this from 🐣 New PR / Untriaged in Apache Cordova: Tooling Pull Requests Sep 27, 2018

@brodybits

This comment has been minimized.

Copy link
Contributor

commented Sep 28, 2018

We just published Cordova CLI 8.1.1 which resolves this issue. In case you encounter this or any other issue in the future please do not hesitate to report it.

@brodybits brodybits closed this Sep 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.