-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support CIO server for wasm-js and js #4466
base: 3.1.0-eap
Are you sure you want to change the base?
Conversation
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.
This is the last PR in a series of ktor server support for wasm-js and js!
Thank you, it's a huge work 🎉
Please, check JVM builds on CI, they fail after two hours with timeout because of hanging NettyHttp2ServerCommonTest
.
ktor-server/ktor-server-cio/posix/src/io/ktor/server/cio/internal/CoroutineUtilsNix.kt
Show resolved
Hide resolved
...ver-test-base/jsAndWasmShared/src/io/ktor/server/test/base/EngineTestBase.jsAndWasmShared.kt
Outdated
Show resolved
Hide resolved
...ver-cio/jsAndWasmShared/src/io/ktor/server/cio/backend/SocketAddressUtils.jsAndWasmShared.kt
Outdated
Show resolved
Hide resolved
@@ -179,6 +179,8 @@ public abstract class BaseApplicationResponse( | |||
} | |||
} catch (closed: ClosedWriteChannelException) { | |||
throw ChannelWriteException(exception = closed) | |||
} finally { | |||
flushAndClose() |
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.
Why do we need to call flushAndClose
inside .use { }
block?
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.
TBH, I'm not fully sure if this fixes the original issue (some tests failure), so I will revert this change...
The idea behind this change is that use
on ByteWriteChannel
is custom and uses close
which in reality calls flushAndClose
, but doesn't wait for it completion.
so use{}
and flushAndClose
are mostly the same, except for the fact that flushAndClose
really suspends
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.
reverted in 9bbd0d3
Now JVM tests are working fine, looks like this was the reason, as this is the only change which affects JVM.
But now testErrorInBodyClosesConnection
started to fail again - it shows it as flaky, so may be it's really related to this fireAndForget close method in channels
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.
@e5l, could you take a look? Should we call flushAndClose
instead of deprecated close
inside of use
?
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.
The difference is in the exception: flushAndClose can throw if the flush is failed. Could you check if this is the case?
...ktor-server-core/jsAndWasmShared/src/io/ktor/server/engine/EmbeddedServer.jsAndWasmShared.kt
Outdated
Show resolved
Hide resolved
c94816f
to
b0029a1
Compare
@osipxd should I create an additional issue for this, or https://youtrack.jetbrains.com/issue/KTOR-865/Add-node.js-server-engine will be fine?
Do you think it will be better to extract those changes and create a separate PR for them? If so, I will do it :) |
@e5l, was this task created for some new Node.js engine or CIO fits the purpose?
Yes, it would be great to discuss this separately. Probably we should deprecate the existing |
Extracted to #4481 |
This reverts commit 33c00f8.
b0029a1
to
d96a40b
Compare
I think we can adjust the issue to include wasm |
Subsystem
Server CIO
Motivation
Probably fixes https://youtrack.jetbrains.com/issue/KTOR-865/Add-node.js-server-engine, though not sure, may be more specific issue should be created
Solution
Most of the code in
ktor-server-cio
is just copied with minor changes.P.S. This is the last PR in a series of
ktor server support for wasm-js and js
! wasm-wasi will be next, probably, if I will be able to find working runtime which supportspreview1
socket APIs...