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 options for corporate proxy support #437

Closed
wants to merge 10 commits into from

Conversation

uxkjaer
Copy link
Member

@uxkjaer uxkjaer commented Jan 7, 2022

fix #285

@cla-assistant
Copy link

cla-assistant bot commented Jan 7, 2022

CLA assistant check
All committers have signed the CLA.

package.json Outdated Show resolved Hide resolved
export type Fetcher = (url: string) => Promise<FetchResponse>;
export type Fetcher = (
url: string,
options: Record<string, unknown>
Copy link
Member

Choose a reason for hiding this comment

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

This options object is awfully vague, do we have any more details on it?

@@ -0,0 +1,25 @@
{
Copy link
Member

Choose a reason for hiding this comment

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

what is package_dist.json?

const proxy = getProxy();
const fetchOptions = proxy
? {
agent: new ProxyAgent(proxy, {
Copy link
Member

Choose a reason for hiding this comment

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

I need to read up on this ProxyAgent.
is it generally safe to use it even when no proxy is needed?
does it have any disadvantage in this flow?

Copy link
Member Author

Choose a reason for hiding this comment

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

well if there is no proxy set, it will be a blank object, so no proxyagent. right now it doesn't work at all without this with corporate proxy

@@ -15,7 +15,7 @@ import { forEach, isPlainObject } from "lodash";

describe("the UI5 language assistant ui5 model", () => {
// The default timeout is 2000ms and getSemanticModel can take ~3000-5000ms
const GET_MODEL_TIMEOUT = 10000;
const GET_MODEL_TIMEOUT = 20000;
Copy link
Member

Choose a reason for hiding this comment

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

Is the increase timeout because your internet connection is slow or because the usage of the proxy agent causes a performance regression?

Copy link
Member Author

Choose a reason for hiding this comment

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

i'll recheck this, it was especially when i tried to use axios, might not need the increase anymore.

@@ -283,7 +284,7 @@ context("The ui5-language-assistant semantic model package API", () => {
});
// TODO: assert no cyclic references in extends or implements or parent - maybe not in a test
});
});
}).timeout(GET_MODEL_TIMEOUT);
Copy link
Member

Choose a reason for hiding this comment

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

if there was no timeout before, does it mean it was the default 2000ms?
if so what changed that requires x10 larger timeout?

Copy link
Member Author

Choose a reason for hiding this comment

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

will check this again with the new proxy

@@ -3,7 +3,8 @@
"compilerOptions": {
"rootDir": ".",
"outDir": "lib",
"baseUrl": "."
"baseUrl": ".",
"strictNullChecks": false
Copy link
Member

Choose a reason for hiding this comment

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

why disable strictNullChecks?

@@ -2,6 +2,8 @@ import { zipObject, keys, map, noop } from "lodash";
import { resolve } from "path";
import { writeFile, mkdirs, pathExists } from "fs-extra";
import fetch from "node-fetch";
import getProxy from "get-proxy";
Copy link
Member

Choose a reason for hiding this comment

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

test-utils does an import for these proxy related packages but without declaring any deps.
Only the types packages are declared but that is not sufficient for runtime.

This works because of how yarn hoists packages to the root node_modules dir, but it is still in-correct deps management when we do not declare a runtime dependency...

agent: new ProxyAgent(proxy, {
// Options, with all defaults
tunnel: true, // If true, will tunnel all HTTPS using CONNECT method
timeout: 5000, // Time in milli-seconds, to maximum wait for proxy connection to establish
Copy link
Member

Choose a reason for hiding this comment

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

is 5000 a reasonable timeout? or too large?

Copy link
Member Author

Choose a reason for hiding this comment

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

the 5000 was the default from the repo

@petermuessig
Copy link
Contributor

Closed in favor of #475

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto complete doesn't work with corporate proxy
3 participants