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

fix: add https-proxy-agent to fetch requests #1433

Merged
merged 20 commits into from
Feb 29, 2024
Merged

Conversation

malis42
Copy link
Contributor

@malis42 malis42 commented Feb 13, 2024

What/Why/How?

Adding https-proxy-agent package to fix issues with requests when using CLI behind proxy. Create better mechanism for handling env.REDOCLY_DOMAIN usage in few modules.

Now if you need to run the CLI tool behind a proxy, you can use the HTTP_PROXY and HTTPS_PROXY environment variables to configure the proxy settings.

https-proxy-agent package was used for node-fetch requests. Now we pass agent for every fetchWithTimeout request, as well as other regular fetch request.

Reference

Resolves #1404
Fixes #529
Fixes #1146

Testing

Fixed unit tests. Tested with few CLI commands: push, lint etc.

Screenshots (optional)

n/a

Has code been changed?

Yes

Check yourself

  • Code is linted
  • Tested with redoc/reference-docs/workflows (internal)
  • All new/updated code is covered with tests

Security

  • Security impact of change has been considered
  • Code follows company security practices and guidelines

Copy link

changeset-bot bot commented Feb 13, 2024

🦋 Changeset detected

Latest commit: 50f5541

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@redocly/openapi-core Minor
@redocly/cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Feb 13, 2024

Command Mean [s] Min [s] Max [s] Relative
redocly lint packages/core/src/benchmark/benches/rebilly.yaml 1.133 ± 0.035 1.101 1.218 1.00
redocly-next lint packages/core/src/benchmark/benches/rebilly.yaml 1.158 ± 0.030 1.103 1.206 1.02 ± 0.04

Copy link
Contributor

github-actions bot commented Feb 13, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 76.95% 4468/5806
🟡 Branches 67.05% 2362/3523
🟡 Functions 70.41% 728/1034
🟡 Lines 77.17% 4204/5448
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / domains.ts
100% 76.92% 100% 100%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟡
... / config.ts
70.32%
77.3% (+1.11% 🔼)
67.86% (-1.11% 🔻)
70%
🟡
... / index.ts
63.64% (-3.03% 🔻)
67.86% (-3.57% 🔻)
73.91% (-1.09% 🔻)
63.64% (-3.03% 🔻)
🟡
... / push.ts
73.53% 68.46% 54.55% 75.93%
🟡
... / api-client.ts
75.44% (-4.56% 🔻)
41.38% (-4.77% 🔻)
75%
74.55% (-4.62% 🔻)

Test suite run success

722 tests passing in 102 suites.

Report generated by 🧪jest coverage report action from 50f5541

@lornajane
Copy link
Contributor

Cool! I think this relates to some open issue(s) though, could you link them from the PR description?

@malis42 malis42 marked this pull request as ready for review February 14, 2024 10:37
@malis42 malis42 requested review from a team as code owners February 14, 2024 10:37
Copy link
Contributor

@tatomyr tatomyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please test this in Workflows and add some docs for the new proxy feature.
Could you also update the description so it reflects how to use the proxy feature and how #1404 got resolved?

packages/core/src/domains.ts Outdated Show resolved Hide resolved
packages/core/src/utils.ts Outdated Show resolved Hide resolved
packages/core/src/utils.ts Show resolved Hide resolved
Copy link
Contributor

github-actions bot commented Feb 16, 2024

Command Mean [ms] Min [ms] Max [ms] Relative
redocly lint packages/core/src/benchmark/benches/rebilly.yaml 985.9 ± 12.9 960.7 1001.8 1.00
redocly-next lint packages/core/src/benchmark/benches/rebilly.yaml 986.6 ± 19.7 952.5 1016.0 1.00 ± 0.02

Copy link
Contributor

@IgorKarpiuk IgorKarpiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@tatomyr tatomyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a minor comment. Otherwise looks good.

packages/core/src/redocly/domains.ts Outdated Show resolved Hide resolved
@malis42 malis42 force-pushed the fix/https-proxy-issues-fix branch from 368c353 to 50f5541 Compare February 29, 2024 11:40
@malis42 malis42 merged commit 2639dc4 into main Feb 29, 2024
31 checks passed
@malis42 malis42 deleted the fix/https-proxy-issues-fix branch February 29, 2024 11:55
RomanHotsiy added a commit that referenced this pull request Feb 29, 2024
RomanHotsiy added a commit that referenced this pull request Feb 29, 2024
malis42 added a commit that referenced this pull request Feb 29, 2024
malis42 added a commit that referenced this pull request Mar 4, 2024
…ges (#1461)

* Reapply "fix: add https-proxy-agent to fetch requests (#1433)" (#1458)
* fix: add https-proxy-agent package to browser excluded packages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants