Menu

1 / 4

Kotlin Coroutines to TypeScript: Three Cancellation Patterns That Aren't 1:1

DEV Community·Gabriel Anhaia·6 months ago
#5MC39FBT
#pattern#typescript#kotlin#signal#fetch
Reading 0:00
15s threshold

Book: Kotlin and Java to TypeScript — A Bridge for JVM Developers

Also by me: The TypeScript Library — the 5-book collection

My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools

Me: xgabriel.com | GitHub

A Kotlin engineer ports their first non-trivial service to Node. The handler launches three calls in parallel, the request times out, and the engineer expects the in-flight work to stop. It does not. Two of the three downstream calls finish ten seconds later, write to the database, and emit a metric for a request whose response was already a 504.

In Kotlin, that bug does not exist. Every coroutineScope and every launch belongs to a parent. The runtime cancels every child recursively and atomically when the parent is cancelled. It is not a library feature. It is the central design decision of kotlinx.coroutines . The Kotlin docs call it structured concurrency .

JavaScript has none of this. A Promise does not have cancel() .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.