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

Can't set agents when agent type is false #2360

Open
1 of 2 tasks
shellvon opened this issue Jun 23, 2024 · 0 comments
Open
1 of 2 tasks

Can't set agents when agent type is false #2360

shellvon opened this issue Jun 23, 2024 · 0 comments

Comments

@shellvon
Copy link

Describe the bug

  • Node.js version:
  • OS & version:

Currently , the agent type is:

export type Agents = {
http?: HttpAgent | false;
https?: HttpsAgent | false;
http2?: unknown | false;
};

as you can see, false is a valid type, but when i set agent to false, it throws an error!

got/source/core/options.ts

Lines 1136 to 1146 in 23b2f26

set agent(value: Agents) {
assert.plainObject(value);
// eslint-disable-next-line guard-for-in
for (const key in value) {
if (!(key in this._internals.agent)) {
throw new TypeError(`Unexpected agent option: ${key}`);
}
// @ts-expect-error - No idea why `value[key]` doesn't work here.
assert.any([is.object, is.undefined], value[key]);

Actual behavior

Can't set agent when agent type is false

Expected behavior

change type declare (maybe remove false type?) or just make false as a valid type when set agent, I think the latter would be better.

Code to reproduce

// just set agent to false.

Checklist

  • I have read the documentation.
  • I have tried my code with the latest version of Node.js and Got.
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

No branches or pull requests

1 participant