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

chore(agnostification): agnostify web socket connections #6520

Merged
merged 1 commit into from Oct 19, 2020

Conversation

jackfranklin
Copy link
Collaborator

@jackfranklin jackfranklin commented Oct 16, 2020

This PR updates the socket transport code to swap between a Node web socket transport or a web one based on isNode. It also adds unit tests to the browser tests that show we can connect in a browser.

Copy link
Contributor

@paullewis paullewis left a comment

Choose a reason for hiding this comment

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

LGTM with nits.

const getWebSocketTransportClass = async () => {
return isNode
? (await import('../node/NodeWebSocketTransport.js')).NodeWebSocketTransport
: (await import('./BrowserWebSocketTransport.js'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Does there need to be a subdirectory for browser-centric code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I think probably there does. But then it'll get a bit messy with node/browser/common where common will sometimes conditionally load in things. But maybe that's fine?

I might leave this for a follow up PR - let me know if you feel strongly to fix this now 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't personally think it's a blocker if you're planning to do it anyway.

src/common/BrowserWebSocketTransport.ts Outdated Show resolved Hide resolved
src/common/BrowserWebSocketTransport.ts Outdated Show resolved Hide resolved
@@ -22,7 +22,7 @@ import { assert } from '../common/assert.js';
import { helper, debugError } from '../common/helper.js';
import { LaunchOptions } from './LaunchOptions.js';
import { Connection } from '../common/Connection.js';
import { WebSocketTransport } from '../common/WebSocketTransport.js';
import { NodeWebSocketTransport as WebSocketTransport } from '../node/NodeWebSocketTransport.js';
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to rename the import? Might be better to refactor it to use the new name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I think so. Will rework in follow-up.

This PR updates the socket transport code to swap between a Node web
socket transport or a web one based on the `isNode` environment. It also
adds unit tests to the browser tests that show we can connect in a
browser.
@jackfranklin jackfranklin merged commit f63a123 into main Oct 19, 2020
@jackfranklin jackfranklin deleted the browser-socket-transport branch October 19, 2020 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants