emacs-deferred
emacs-deferred copied to clipboard
Most robust way to "finally" processing?
The documentation warns that sometimes a "finally" block may not be executed due to asynchrony. If I have some clean-up code that needs to be run no matter how a deferred chain terminates, what's the best, most robust way to do that? I worry about implementing cleanup code that silently gets ignored sometimes.
Hi @abingham
When some deferred task fails to call the callback function without appropriate error handling, the subsequent tasks can not be executed for ever. In this case, the 'finally' block will not be executed. Not only coding bugs on elisp, but also external processes cause to break deferred flows, such as unexpected freezing, undetectable exiting, packet loss and some I/O error with disk or network.
So, the robust clean up way for asynchronous flow is making the time-out block. Please see the document for the details. https://github.com/kiwanami/emacs-deferred#timeout