Coder Social home page Coder Social logo

arrow-kt / suspendapp Goto Github PK

View Code? Open in Web Editor NEW
71.0 18.0 4.0 1.39 MB

Reason about resource-safety in the same way you reason about Structured Concurrency with SuspendApp!

Home Page: https://arrow-kt.github.io/suspendapp/

License: Apache License 2.0

Kotlin 100.00%
arrow-kt kotlin kotlin-coroutines kotlin-jvm kotlin-multiplatform kotlin-native kotlin-nodejs kotlinx-coroutines structured-concurrency

suspendapp's People

Contributors

atternatt avatar gutiory avatar kantis avatar nomisrev avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

suspendapp's Issues

HTTP inflight request is aborted ignoring preWait

Issue: http inflight request is aborted on app getting e.g. SIGTERM even though SuspendApp preWait is configured to be e.g. 10s.

Expectation: http inflight requests are allowed to complete within preWait on app getting e.g. SIGTERM.

Steps to reproduce: (example app code issue-suspendapp-inflight-abort.zip)

  • Start app with -Dio.ktor.server.engine.ShutdownHook=false
  • curl http://localhost/ping -v
  • kill -s SIGTERM `lsof -t -i:80`
  • Inflight request is aborted immediately ignoring preWait

Looks like an issue is with Ktor itself as I also get the same outcome using just Ktor embeddedServer (also raised an issue with Ktor)
Nevertheless I thought maybe Arrow community could also help investigating this issue.

Gradle Ctrl-C Not Terminating Ktor SuspendApp

Repro Steps:
https://github.com/jamesward/kmp-conf-server

./gradlew runDebugExecutableLinuxX64

(Not sure if the same problem exists on Mac)

Hit Ctrl-C and see the Gradle process end, but the native server process continues running even after multiple minutes:

$ ps auxwww|grep kmp-conf-server
jw        847540  0.1  0.0 554808 28072 ?        Sl   16:09   0:00 /home/jw/projects/kmp-conf-server/build/bin/linuxX64/debugExecutable/kmp-conf-server.kexe

SIGINT event in windows terminal does not terminate the jar application (using ktor module)

I used the Ktor example of SuspendApp and generated a jar file.
When run on windows, the process does not terminate on SIGINT (Ctrl+c). Notably, the ktor server shuts down, nevertheless the process still keeps running. When pressing Ctrl+c another time, the processes finally terminates. On linux however (using the same jar), the application terminates gracefully as expected.

fun main() = SuspendApp {
  resourceScope {
    server(Netty) { ... }
    awaitCancellation()
  }
}

image

Setup Java in Kotlin MPP Example

The example module currently doesn't setup the Java app.
Upon setting up the example module we ran into some issues setting up Java from a Kotlin MPP project.

It didn't correctly link the Main-Class in the Manifest when configuring from the regular Java Gradle DSL.
Neither Google, nor Kotlin Slack gave me an quick solution so I opted to move it out of the scope of PR #4.

preWait not working since Ktor v2.3.0 by default

Since Ktor v2.3.0 shutdown hook was added to Ktor engines e.g. CIO and Netty, making Ktor server to stop before waiting a preWait duration configured by SuspendApp.
Adding an example project to reproduce this issue issue-demo.zip

Steps to reproduce it:

  • Start app with -Dio.ktor.server.engine.ShutdownHook=true (true by default)
  • curl http://localhost/ping -v to get 200 response
  • kill -s SIGTERM `lsof -t -i:80`
  • curl http://localhost/ping -v again to get an error while it is expected to get 200 response for a period of preWait duration before engine.stop is called.

Setting -Dio.ktor.server.engine.ShutdownHook=false fixes this issue.
To save developers time troubleshooting this issue, probably SuspendApp readme/docs should mention this Ktor engine configuration bit making sure SuspendApp works as expected?
Also might be worth adding an integration test to cover this behaviour.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/generate-alpha-tag.yaml
  • actions/checkout v4
  • actions/setup-java v4
  • gradle/gradle-build-action v3
  • actions/checkout v4
  • actions/setup-java v4.2.1
  • gradle/gradle-build-action v3
.github/workflows/generate-tag.yaml
  • actions/checkout v4
  • actions/setup-java v4
  • gradle/gradle-build-action v3
  • actions/checkout v4
  • actions/setup-java v4.2.1
  • gradle/gradle-build-action v3
.github/workflows/publish.yml
  • actions/checkout v4
  • actions/setup-java v4
  • gradle/gradle-build-action v3
  • actions/upload-artifact v4
  • gradle/gradle-build-action v3
  • gradle/gradle-build-action v3
.github/workflows/pull_request.yml
  • actions/checkout v4
  • actions/setup-java v4
  • gradle/gradle-build-action v3
  • actions/upload-artifact v4
  • actions/checkout v4
  • actions/setup-java v4
  • gradle/gradle-build-action v3
  • stefanzweifel/git-auto-commit-action v5
gradle
gradle.properties
settings.gradle.kts
build.gradle.kts
example/build.gradle.kts
gradle/libs.versions.toml
  • org.jetbrains.kotlinx:kotlinx-coroutines-core 1.8.1
  • org.jetbrains.kotlinx:kotlinx-knit 0.5.0
  • io.ktor:ktor-server-host-common 2.3.11
  • io.arrow-kt:arrow-fx-coroutines 1.2.4
  • io.arrow-kt.arrow-gradle-config-formatter 0.12.0-rc.6
  • io.arrow-kt.arrow-gradle-config-nexus 0.12.0-rc.6
  • io.arrow-kt.arrow-gradle-config-publish 0.12.0-rc.6
  • io.arrow-kt.arrow-gradle-config-versioning 0.12.0-rc.6
  • org.jetbrains.dokka 1.9.20
  • org.jetbrains.kotlin.multiplatform 1.9.24
  • org.jetbrains.kotlin.jvm 1.9.24
  • org.jetbrains.kotlinx.binary-compatibility-validator 0.14.0
  • org.jetbrains.kotlinx.knit 0.5.0
suspendapp-ktor/gradle.properties
suspendapp-ktor/build.gradle.kts
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 8.8

  • Check this box to trigger a request for Renovate to run again on this repository

LinuxArm64 support

Can we add support for LinuxArm64 also? Getting the following error

:shared:linuxArm64Main: Could not resolve io.arrow-kt:suspendapp:0.4.1-alpha.5.

Completing Backpressure Deferrable Deadlocks

Kotlin version: 1.9.21
Native Platform build: linuxX64
OS: Ubuntu 23.10

I tried the "Simple Example" from the README.MD, but the backpressure communication via the CompletableDeferred<Int> seems the get deadlocked and the simple example never terminates. Triggering the kill signal (SIGINT or SITGERM) gets correctly communicated to the arrow.continuations.unsafe.Unsafe#onShutdown hook, but the shutdown hook never returns from the call to BACKPRESSURE.complete(..) and the waiting signal handler never gets released. Providing a timeout to arrow.continuations.SuspendAppKt#SuspendApp has no effect.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.