-
-
Notifications
You must be signed in to change notification settings - Fork 402
Closed
Description
Bug
When running npx -p yo -p @custom/generator-custom-app -c 'yo @custom/custom-app, an error TypeError: Cannot read property 'proxy' of undefined occurs.
My environment
- OS version/details:
macOS 10.14.5 - Node version:
v12.4.0 - npm version:
6.9.0 - Version of yo :
2.0.6
Expected behavior
Yeoman not to encounter TypeError: Cannot read property 'proxy' of undefined
Current behavior
Yeoman encounters TypeError: Cannot read property 'proxy' of undefined:
TypeError: Cannot read property 'proxy' of undefined
at new OuterHttpAgent (/Users/P781555/.npm/_npx/29063/lib/node_modules/yo/node_modules/global-tunnel-ng/lib/agents.js:17:28)
at new ClientRequest (_http_client.js:116:13)
at TunnelingAgent.request (http.js:44:10)
at TunnelingAgent.createSocket (/Users/P781555/.npm/_npx/29063/lib/node_modules/yo/node_modules/tunnel/lib/tunnel.js:126:25)
at TunnelingAgent.createSecureSocket [as createSocket] (/Users/P781555/.npm/_npx/29063/lib/node_modules/yo/node_modules/tunnel/lib/tunnel.js:207:41)
at TunnelingAgent.addRequest (/Users/P781555/.npm/_npx/29063/lib/node_modules/yo/node_modules/tunnel/lib/tunnel.js:84:8)
at new ClientRequest (_http_client.js:276:16)
at Object.request (https.js:309:10)
at Object.request (/Users/P781555/.npm/_npx/29063/lib/node_modules/yo/node_modules/global-tunnel-ng/index.js:336:40)
at get (/Users/P781555/.npm/_npx/29063/lib/node_modules/yo/node_modules/latest-version/node_modules/got/index.js:33:18)
(node:29391) UnhandledPromiseRejectionWarning: Error: callback() can only be called once.
at onetime (/Users/P781555/.npm/_npx/29063/lib/node_modules/yo/node_modules/each-async/node_modules/onetime/index.js:15:11)
at /Users/P781555/.npm/_npx/29063/lib/node_modules/yo/node_modules/yeoman-doctor/lib/index.js:23:7
at /Users/P781555/.npm/_npx/29063/lib/node_modules/yo/node_modules/yeoman-doctor/lib/rules/yo-version.js:21:23
(node:29391) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:29391) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Steps to reproduce the behavior
Not easy to replicate (using private NPM repository with a custom generator). But the error seems to happen in this line:
mixinProxying(this, opts.proxy);
of .npm/_npx/29063/lib/node_modules/yo/node_modules/global-tunnel-ng/lib/agents.js:
/* jshint node:true */
'use strict';
var util = require('util');
var http = require('http');
var HttpAgent = http.Agent;
var https = require('https');
var HttpsAgent = https.Agent;
var pick = require('lodash/pick');
/**
* Proxy some traffic over HTTP.
*/
function OuterHttpAgent(opts) {
HttpAgent.call(this, opts);
mixinProxying(this, opts.proxy);
}
util.inherits(OuterHttpAgent, HttpAgent);
exports.OuterHttpAgent = OuterHttpAgent;
/**
* Proxy some traffic over HTTPS.
*/
function OuterHttpsAgent(opts) {
HttpsAgent.call(this, opts);
mixinProxying(this, opts.proxy);
}
util.inherits(OuterHttpsAgent, HttpsAgent);
exports.OuterHttpsAgent = OuterHttpsAgent;
/**
* Override createConnection and addRequest methods on the supplied agent.
* http.Agent and https.Agent will set up createConnection in the constructor.
*/
function mixinProxying(agent, proxyOpts) {
agent.proxy = proxyOpts;
var orig = pick(agent, 'createConnection', 'addRequest');
// Make the tcp or tls connection go to the proxy, ignoring the
// destination host:port arguments.
agent.createConnection = function(port, host, options) {
return orig.createConnection.call(this, this.proxy.port, this.proxy.host, options);
};
agent.addRequest = function(req, options) {
req.path =
this.proxy.innerProtocol + '//' + options.host + ':' + options.port + req.path;
return orig.addRequest.call(this, req, options);
};
}
magickaichen
Metadata
Metadata
Assignees
Labels
No labels