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

feat: implement getAgent function #38

Merged
merged 1 commit into from
May 15, 2023
Merged

feat: implement getAgent function #38

merged 1 commit into from
May 15, 2023

Conversation

nlf
Copy link
Contributor

@nlf nlf commented May 11, 2023

note that i chose to remove the lambda specific handling, it doesn't make much sense to me to arbitrarily turn off keepalives just because a fetch is being performed in a lambda.

other than that, this is meant to be functionally equivalent to the lib/agent.js file in make-fetch-happen

@nlf nlf requested a review from a team as a code owner May 11, 2023 20:03
Comment on lines +10 to +15
for (const [key, value] of Object.entries(process.env)) {
const lowerKey = key.toLowerCase()
if (['https_proxy', 'http_proxy', 'proxy', 'no_proxy'].includes(lowerKey)) {
proxyEnv[lowerKey] = value
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for (const [key, value] of Object.entries(process.env)) {
const lowerKey = key.toLowerCase()
if (['https_proxy', 'http_proxy', 'proxy', 'no_proxy'].includes(lowerKey)) {
proxyEnv[lowerKey] = value
}
}
for (const key in process.env) {
const lowerKey = key.toLowerCase()
if (['https_proxy', 'http_proxy', 'proxy', 'no_proxy'].includes(lowerKey)) {
proxyEnv[lowerKey] = process.env[key]
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Sadly, Object.entries does not return an iterator.

Copy link
Member

Choose a reason for hiding this comment

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

This will "somewhat" nondeterministically clobber entries w/ duplicated content based on casing and I think we should acknowledge that here in this review and say "Yeah we don't support that"

})

if (matches) {
proxy = ''
Copy link
Member

Choose a reason for hiding this comment

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

this is weird, why an empty string instead of null or undefined?

}

const timeouts = [
options.timeouts.connection || 0,
Copy link
Member

Choose a reason for hiding this comment

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

Should normalizeOptions do this?

options.timeouts.transfer || 0,
].join('.')

const maxSockets = options.maxSockets || 15
Copy link
Member

Choose a reason for hiding this comment

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

Should normalizeOptions do this/

const key = [
`https:${isHttps}`,
proxyDescriptor,
`local-address:${options.localAddress || 'null'}`,
Copy link
Member

Choose a reason for hiding this comment

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

More defaults here, same question about normalizeOptions

@nlf nlf merged commit 93bdc11 into main May 15, 2023
@nlf nlf deleted the nlf/add-getAgent branch May 15, 2023 18:19
@github-actions github-actions bot mentioned this pull request May 15, 2023
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.

2 participants