-
Notifications
You must be signed in to change notification settings - Fork 290
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
Add a new overload of Socket::handleProxyStatus for internal use #975
Conversation
src/workerd/api/sockets.c++
Outdated
void Socket::handleProxyStatus(jsg::Lock& js, kj::Promise<kj::Maybe<kj::Exception>> connectResult) { | ||
// It's kind of weird to take a promise that resolves to a Maybe<Exception> but we can't just use | ||
// a Promise<void> and put our logic in the error handler because awaitIo's errorFunc isn't passed | ||
// the jsg::Lock, which we need to have in the error case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for later: should we update awaitIo
so that it does pass the jsg::Lock
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should also update it to be awaitable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this sounds like a bug in awaitIo
that we should just fix instead of work around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a little bit more than I had mentioned previously -- currently the only code path that passes a jsg::Lock
is if your awaited promise resolves to a non-void result and if you're on the success callback. Even if I added a jsg::Lock
to the error callback that wouldn't help in this particular case since I had been trying to use a Promise<void>
, and as of today both the success and error callbacks aren't given a jsg::Lock
in that case.
I'll leave it as a cleanup for now rather than boiling the ocean on all the awaitIo
overloads.
src/workerd/api/sockets.c++
Outdated
auto result = context.awaitIo(js, kj::mv(connectResult), | ||
[this, self = JSG_THIS](jsg::Lock& js, kj::Maybe<kj::Exception> result) -> void { | ||
KJ_IF_MAYBE(e, result) { | ||
auto exc = kj::Exception(kj::Exception::Type::FAILED, __FILE__, __LINE__, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking nit: use KJ_EXCEPTION
or JSG_KJ_EXCEPTION
here?
src/workerd/api/sockets.c++
Outdated
auto exc = kj::Exception(kj::Exception::Type::FAILED, __FILE__, __LINE__, | ||
kj::str(JSG_EXCEPTION(Error), "connection attempt failed")); | ||
resolveFulfiller(js, exc); | ||
readable->getController().cancel(js, nullptr).markAsHandled(js); | ||
writable->getController().abort(js, nullptr).markAsHandled(js); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: refactor into a function since the other handleProxyStatus has the same code
936c7a2
to
be54eaa
Compare
The fixup commit is here (posting since github doesn't appear to show it anymore): 936c7a2 |
So that I can handle initial connection errors on connections that were established without using HTTP connect.
be54eaa
to
de653b5
Compare
So that I can handle initial connection errors on connections that were established without using HTTP connect.