-
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?
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.
Do you think may be it will be better to create a separate issue for this to investigate? :)
I see, that the same test fails sometimes (flaky) not only for js/wasm-js. And as I reverted this change, it should not affect anything.
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.
Yes, let's move this investigation into a separate task
...ktor-server-core/jsAndWasmShared/src/io/ktor/server/engine/EmbeddedServer.jsAndWasmShared.kt
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 |
* Use stdlib `use` extension-function * Update type checks
Co-authored-by: Osip Fatkullin <[email protected]>
…torio#4411) * Drop `jvmAndNix` shared source set * Commonize `ktor-network` and `ktor-network-tls` * Support TCP and Unix sockets for wasm-js and js on Node * Move `supportsUnixDomainSockets` to posix and use Platform instead of expect/actual
* Support multiple client engines for JS/WasmJs * CIO client Js/WasmJs support * Enable CIO tests in client tests * Make client engines `data object` to have `toString` * Make ClientLoader work with multiple engines on js/wasmJs and so test CIO engine on nodejs(js+wasmJs)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* Test libcurl build with conan * Take both curl and openssl from the same build * test no linux cache * Move K/N linux cache disabling to just `ktor-client-curl` module
Some services use 403 instead of 401. Changing them might be impossible. With this change Ktor can flexibly work with any broken service. --------- Co-authored-by: Osip Fatkullin <[email protected]>
* KTOR-7679 Allow disabling body decoding on server
…EmbeddedServer.stop (ktorio#4481) * Add startSuspend/stopSuspend in EmbeddedServer * Make EngineTestBase work on js/wasmJs
This reverts commit 33c00f8.
b0029a1
to
d96a40b
Compare
I think we can adjust the issue to include wasm |
Hey @osipxd I've rebased PR on latest changes (e.g I saw, that there is some progress to improve tests stability, but those changes are only in |
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.
Thank you! LGTM
As we decided to move investigation of the flaky test to a separate task, it would be great to ignore this test. However, I don't think it is possible to ignore a test only on one platform. I thought about adding annotations like @JsIgnore
, @JvmIgnore
, etc., but it feels out of the task scope. I think we'll merge tests stabilizing changes today, so we'll check if it helps.
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...