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

socketPath option is not passed to the connect function #3486

Open
zdm opened this issue Aug 19, 2024 · 15 comments
Open

socketPath option is not passed to the connect function #3486

zdm opened this issue Aug 19, 2024 · 15 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@zdm
Copy link

zdm commented Aug 19, 2024

Bug Description

In Pool dispatcher socketPath option is not passed to the connect if connect is a function.

Reproducible By

const dispatcher = new Agent ( {
    socketPath: "/var/run/socket",
    connect ( options, callback ) {
        console.log( options );
        process.exit();
    }
} )

await fetch( "http://local/", {
    dispatcher
} );

Expected Behavior

Expecting to see socketPath in options, passed to the connect function.

When connect is specified as object - it works, but for function you just forget to pass socketPath.

Logs & Screenshots

Environment

Additional context

@zdm zdm added the bug Something isn't working label Aug 19, 2024
@metcoder95
Copy link
Member

Good catch, would you like to send a PR?

@metcoder95 metcoder95 added the good first issue Good for newcomers label Aug 20, 2024
@Uzlopak
Copy link
Contributor

Uzlopak commented Aug 20, 2024

@metcoder95
Actually i doubt that this is a bug. If I read the code it looks like it was on purpose not allowed to manipulate the socketPath.

@zdm
Copy link
Author

zdm commented Aug 20, 2024

Hmm, bit if we specify socketPath, connect function should receive if, or how it should work?

@metcoder95
Copy link
Member

metcoder95 commented Aug 20, 2024

Well, in theory it should, we are just not passing it to the connect factory .

We have documented that we support these options to the default connector factory. I'd also expect that they are passed down to the custom factory that its submitted.

@zdm
Copy link
Author

zdm commented Aug 20, 2024

Ok. what is your decision?
I cam make PR it this is a bug.

@zdm
Copy link
Author

zdm commented Aug 20, 2024

I think it should be fixed.
If user do not want to change socketPath in the future - he can use closure, but by default this parameter should pass.

@mcollina
Copy link
Member

I think a PR with the change would help us spot why we did not pass it. If it's that's the case there is likely a test to cover it.

@metcoder95
Copy link
Member

+1

@Uzlopak
Copy link
Contributor

Uzlopak commented Aug 21, 2024

What happens if you specify some file like /etc/passwd as socketPath?

@zdm
Copy link
Author

zdm commented Aug 21, 2024

What happens if you specify some file like /etc/passwd as socketPath?

Error, because this is not a socket.

@zdm
Copy link
Author

zdm commented Aug 21, 2024

So, I carefully looked at the code.
sockerPath should behave like localAddress option.
It should be removed from buildConnector options and added to the connect call options.
This will be a breaking change because type script interfaces will be changed.

@zdm
Copy link
Author

zdm commented Aug 21, 2024

timeout also not passed to connect function.
I think all options, which are passed to the buildConnector should be passed to the connect function without exclusions.

@metcoder95
Copy link
Member

We are preparing the cut for new major, so it should be ok to do breaking changes.

Feel free to move forward with a PR so we can iterate over it

@Uzlopak
Copy link
Contributor

Uzlopak commented Aug 21, 2024

It is actually breaking if we add more options?

@metcoder95
Copy link
Member

I think refers to removing it from buildConnector.

Not so sure we should do that, but maybe I'm overseeing something; happy to see the PR to validate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants