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(runtime/http): websocket support #10359

Merged
merged 44 commits into from
Jul 8, 2021

Conversation

crowlKats
Copy link
Member

Closes #10211


return { request, respondWith };
return { request, respondWith, upgradeWebsocket };
Copy link

@ije ije Apr 25, 2021

Choose a reason for hiding this comment

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

can we use upgrade instead of upgradeWebsocket? a simple API can get better dev experience.

Copy link
Member Author

@crowlKats crowlKats Apr 25, 2021

Choose a reason for hiding this comment

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

No, upgrading isn't something exclusive to websockets. that would end up being misleading and confusing.
9 more characters in a function name used in a single place wont affect dev experience.
Of course that would make sense if we would support upgrading other kind of conns out of the box

Copy link
Collaborator

Choose a reason for hiding this comment

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

Of course that would make sense if we would support upgrading other kind of conns out of the box

Other hypothetical upgrades would have different return types, so they should just have individual names anyway.

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

Is this actually working? Would be very nice to have a test in cli/tests/unit/http_test.ts if so.

@crowlKats
Copy link
Member Author

@ry well we first need #10365

Copy link
Contributor

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

Needs regression tests but LGTM apart from that, thanks!

runtime/js/40_http.js Outdated Show resolved Hide resolved
runtime/js/40_http.js Outdated Show resolved Hide resolved
runtime/js/40_http.js Outdated Show resolved Hide resolved
@ry
Copy link
Member

ry commented May 5, 2021

@crowlKats I'm a bit confused about how this depends on #10365... I haven't dived into this PR but I'm not sure why we would need to expose WebSocketStream in order to hook up the hyper-tungstenite bindings?

I don't care so much about WebSocketStream support - since it's still a tentative API - but I'm rather keen to land this PR.

crowlKats and others added 6 commits May 5, 2021 14:01
Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
# Conflicts:
#	extensions/websocket/lib.rs
#	runtime/ops/http.rs
#	runtime/ops/websocket.rs
runtime/js/40_http.js Outdated Show resolved Hide resolved
crowlKats and others added 2 commits May 5, 2021 17:58
Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
runtime/js/40_http.js Outdated Show resolved Hide resolved
@bartlomieju bartlomieju added this to the 1.12.0 milestone Jun 25, 2021
runtime/js/40_http.js Outdated Show resolved Hide resolved
@lucacasonato
Copy link
Member

Blocked on hyperium/hyper#2587

Copy link
Member

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for this great feature!

We need to add some documentation for this to https://deno.land/manual@v1.11.5/runtime/http_server_apis in a follow up commit.

Copy link
Member

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

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

Oh actually upgradeWebsocket is still async. That needs to become synchronous.

Copy link
Member

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

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

LGTM now. Thanks!

@lucacasonato lucacasonato merged commit 5e092b1 into denoland:main Jul 8, 2021
@crowlKats crowlKats deleted the native_http_websocket branch July 8, 2021 15:30
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.

Support web sockets with hyper binding
7 participants