Skip to content

[BUG] TypeError: e is not a constructor when HTTP_PROXY/HTTPS_PROXY env vars are set (regression in v2.33.0) #1204

@bux

Description

@bux

Since v2.33.0, the CLI crashes at startup with TypeError: e is not a constructor whenever HTTP_PROXY, http_proxy, HTTPS_PROXY, or https_proxy environment variables are set. This is a regression introduced by PR #1196 ("update proxy-agent to newer version"), which bumped proxy-agent from 6.5.08.0.1. v2.32.0 is unaffected.

Steps to Reproduce

  1. Set HTTP_PROXY or HTTPS_PROXY (or their lowercase variants) in your environment
  2. Run any openapi-generator-cli command:
HTTP_PROXY=http://proxy.example.com:3128 openapi-generator-cli generate \
  -i openapi.yaml -g typescript-angular -o ./generated
  1. See error

Expected behavior

The CLI should start normally and proceed with code generation, as it did in v2.32.0.

Error shown

TypeError: e is not a constructor
    at Array.<anonymous> (/…/node_modules/@openapitools/openapi-generator-cli/main.js:2:374)
    at o (/…/node_modules/@openapitools/openapi-generator-cli/main.js:2:53914)
    ...
Node.js v20.20.2
Error: Process completed with exit code 1.

Operation System

  • OS: Linux (self-hosted GitHub Actions runner), also reproducible on macOS
  • Version: Ubuntu 22.04 / macOS

Package System

npm

Additional context

The bug is in apps/generator-cli/src/app/app.module.ts (introduced in commit 15a4632, PR #1196):

const ProxyAgent = require('proxy-agent').default ?? require('proxy-agent');
httpModuleConfig.httpAgent = new ProxyAgent(); // ← crashes

proxy-agent@6.5.0 exported the class directly, so require('proxy-agent') was the constructor. proxy-agent@8.0.1 changed to named exports ... require('proxy-agent') now returns { ProxyAgent, ... } with no .default property, so the ?? fallback returns the module object, and new on a plain object throws.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions