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

Allow passthrough of ws options to websocket factory #218

Open
prescience-data opened this issue Sep 23, 2022 · 1 comment
Open

Allow passthrough of ws options to websocket factory #218

prescience-data opened this issue Sep 23, 2022 · 1 comment

Comments

@prescience-data
Copy link

prescience-data commented Sep 23, 2022

Happy to do this as a PR given it seems trivial to add, but prefer to ask before sending unsolicited PRs.

This should allow passing of the parent ws library options to allow setting headers and other environment-specific options that might be required.

A practical example I just ran into was a Chromium fork that requires authentication headers to be sent with the websocket request.

The implementation I'd suggest to avoid breaking any existing API is something like:

import type { ClientOptions } from "ws"
// ... other imports

export default async function openWebSocket(
  url: string,
  raceCancellation?: RaceCancellation,
  clientOptions?: ClientOptions
): Promise<[AttachMessageTransport, CloseWebSocket]> {
  const ws = new NodeWebSocket(url, clientOptions);
  // ... remaining code
}

This allows appending the options as an optional trailing arg which avoids any breaking change or API surface modification.

@krisselden
Copy link
Collaborator

@prescience-data sorry for such a late reply, I'm happy to accept a PR for this. I primarily launch chrome via the stdio pipes method. Also most of this API is composition of apis, the design of this library was to decouple as much as possible via interfaces

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

2 participants