<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">One of the key reasons why you would want to handle those situations is that you may have a leak or other resources, but you may also be handling 99,999 other requests at the same time that you don't want to drop on the floor.<div class=""><br class=""></div><div class="">Even if you put the server into some kind of degraded mode (for example, taking it out of load balancer rotation) and let the requests drain naturally, it's still a lot better than terminating everything immediately.</div><div class=""><br class=""></div><div class="">This isn't an issue in single-user applications but when you have hundreds/thousands of simultaneous users it does limit where crashing the process makes sense.</div><div class=""><br class=""></div><div class="">(Of course, if the server really is deadlocked, then it's going to go down anyway; but if other parts can continue running then why not?)</div><div class=""><br class=""></div><div class="">Alex<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 21 Sep 2017, at 18:53, Daniel Dunbar via swift-dev &lt;<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">It isn’t clear to me how much value this actually adds in a server domain. Inability to recover resources means you may immediate run into deadlocks, for example, so any robust server strategy will end up having to still handle that. If that machinery has to be in place regardless, why not use it for the existing error conditions.<div class=""><br class=""></div><div class="">Do you have any thoughts there?</div><div class=""><br class=""></div><div class="">&nbsp;- Daniel<br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Sep 20, 2017, at 2:55 PM, John Holdsworth via swift-dev &lt;<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello Swift developers,<div class=""><br class=""></div><div class="">I’ve raised a rather speculative PR suggesting a hook be added to stdlib</div><div class="">that would allow users to experiment with error recovery in their apps.</div><div class=""><br class=""></div><div class=""><a href="https://github.com/apple/swift/pull/12025" class="">https://github.com/apple/swift/pull/12025</a></div><div class=""><br class=""></div><div class="">Ultimately it come down to being able to do something like this:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="color: #ba2da2" class="">do</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ba2da2" class="">try</span> <span style="color: #4f8187" class="">Fortify</span>.<span style="color: #31595d" class="">exec</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ba2da2" class="">var</span> a: <span style="color: #703daa" class="">String</span>!</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a = a!</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ba2da2" class="">catch</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3e1e81" class="">NSLog</span>(<span style="color: #d12f1b" class="">"Caught exception: </span>\<span style="color: #d12f1b" class="">(</span>error<span style="color: #d12f1b" class="">)"</span>)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></div><div class=""><br class=""></div><div class="">This was primarily intended for user in "Swift on the server" but could also</div><div class="">help avoid crashes in the mobile domain. The rationale and mechanics</div><div class="">are written up at the following url:</div><div class=""><br class=""></div><div class=""><a href="http://johnholdsworth.com/fortify.html" class="">http://johnholdsworth.com/fortify.html</a></div><div class=""><br class=""></div><div class="">I'll accept this won’t be everybody’s cup of tea but at this stage this is</div><div class="">only an opt-in facilitating patch. Developers need not subject their apps</div><div class="">to this approach which requires a separate experimental implementation.</div><div class=""><br class=""></div><div class="">The recovery is reasonably well behaved except it will not recover&nbsp;</div><div class="">objects and system resources used in intermediate frames, It’s not</div><div class="">as random as something like, for example, trying to cancel a thread.</div><div class=""><br class=""></div><div class="">The debate about whether apps should try to soldier on when something</div><div class="">is clearly amiss is a stylistic one about which there will be a spectrum of</div><div class="">opinions. The arguments weigh more in favour in the server domain.</div><div class=""><br class=""></div><div class="">John</div><div class=""><br class=""></div></div>_______________________________________________<br class="">swift-dev mailing list<br class=""><a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-dev" class="">https://lists.swift.org/mailman/listinfo/swift-dev</a><br class=""></div></blockquote></div><br class=""></div></div>_______________________________________________<br class="">swift-dev mailing list<br class=""><a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-dev<br class=""></div></blockquote></div><br class=""></div></body></html>