$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Behavior of nested async in Kotlin Coroutines
Search
yurihondo
December 18, 2018
Programming
2
1.2k
Behavior of nested async in Kotlin Coroutines
yurihondo
December 18, 2018
Tweet
Share
More Decks by yurihondo
See All by yurihondo
Road to Single Activity Uncovered
yurihondo
0
200
Road to Single Activity
yurihondo
2
780
YouTubeへのライブ配信機能をリリースするまで
yurihondo
0
2.9k
Shibuya.apk_41_DeepDiveintoRememberSaveable.pdf
yurihondo
0
470
Composeでシステムオーバーレイ / System overlay in Compose
yurihondo
0
350
Service由来のViewでViewModelを使えるようにしてみた
yurihondo
2
710
瀕死のシステムが強くなって復活する話
yurihondo
1
520
New UI Design & Debugging Tools In Android Studio
yurihondo
0
710
外部デバイスと密に連携するAndroidアプリに最適なアーキテクチャとは?
yurihondo
0
14k
Other Decks in Programming
See All in Programming
Go コードベースの構成と AI コンテキスト定義
andpad
0
130
Cap'n Webについて
yusukebe
0
130
WebRTC と Rust と8K 60fps
tnoho
2
2k
MAP, Jigsaw, Code Golf 振り返り会 by 関東Kaggler会|Jigsaw 15th Solution
hasibirok0
0
240
AI時代を生き抜く 新卒エンジニアの生きる道
coconala_engineer
1
130
DSPy Meetup Tokyo #1 - はじめてのDSPy
masahiro_nishimi
1
170
Giselleで作るAI QAアシスタント 〜 Pull Requestレビューに継続的QAを
codenote
0
190
Context is King? 〜Verifiability時代とコンテキスト設計 / Beyond "Context is King"
rkaga
10
1.2k
愛される翻訳の秘訣
kishikawakatsumi
3
330
【CA.ai #3】Google ADKを活用したAI Agent開発と運用知見
harappa80
0
310
AtCoder Conference 2025「LLM時代のAHC」
imjk
2
480
AIエンジニアリングのご紹介 / Introduction to AI Engineering
rkaga
8
2.7k
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
9
710
KATA
mclloyd
PRO
33
15k
Scaling GitHub
holman
464
140k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
How to Ace a Technical Interview
jacobian
280
24k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Raft: Consensus for Rubyists
vanstee
141
7.2k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
10
730
Context Engineering - Making Every Token Count
addyosmani
9
510
Done Done
chrislema
186
16k
Transcript
Behavior of nested async in Kotlin Coroutines
About me Androidアプリ開発@DeNA 趣味は、ストリートダンス 今年、長男が爆誕 2 URI 本戸 裕理 (ホンド
ユウリ)
Introduction 今更ですが! Kotlin 1.3より、Coroutineの安定版が 利用できるようになりました 3
Introduction 私が携わるプロジェクトでもCoroutineの アップデートが 行われました 4
Introduction 結果、 アップデート起因のバグを埋め込み、 修正をする事になりました 5
Introduction そう、 あるあるです 6
Introduction (流出はしていません) 一応、最近センシティブだからね 7
Introduction 今日は、バグ対応から学んだ ◦ ネストしたasyncの振舞いと対応方法 について簡単にお話させて頂きます 8
ネストしたasyncの振舞いと対応方法 9
ver. 0.30.0より、ネストしたasyncのキャンセルが、 親のcoroutineにも伝播するようになったため、 今までエラーハンドリングを意識していなかった 箇所で例外が発生した 該当のFeature <https://github.com/Kotlin/kotlinx.coroutines/releases/tag/0.30.0> Overview for Bug
10
例えば、 以下のようなケースで例外が発生するようになった Example 11
例外が親のlaunchにも伝播する Example 12 Exception
Solution 1 withContextを利用 13
Solution 2 スコープを切り替える 14
今回の例であれば、launchにCoroutineExceptionHandler を渡して ネストされたのCoroutineのエラーをまとめてしまう Solution 3 例外の集約 15
※以下は、supervisorScopeの例 Solution 4 Supervisionを導入 16
まとめ 17 これからネスト状態でasyncを扱うときは... 1. withContextを使う 2. Suspend関数に切り出す 3. 例外の集約 4.
Supervisionの導入 辺りを検討できると良いかも...そして...
まとめ 18 Release Note は、しっかり読みましょう!!! (自戒)
Reference 今回の発表の不明点は、以下でほぼ解消されます 19 ◦ Kotlin Coroutines 0.30.2のExceptionが伝わる仕組み <https://qiita.com/takahirom/items/2846caa1d51e868ef88b> ◦ Kotlin
Coroutine 1.0.0までに夏から変わったところ <http://sys1yagi.hatenablog.com/entry/2018/12/08/181232>
THANKS! You can find me at: Twitter : URI -
@yuyuyuyuyuri Pokemon GO : 05URI28 - 0188 7196 1789 20