I need to execute some synchronous code after an asynchrnous Promise is resolved. Currently my code looks like this:
console.log("Starting");
promiseFunc().
then(function() {
  console.log("PromiseFunc done. Doing Synchronous work...");
  synchronousFunc1();
  synchronousFunc2();
  console.log("Synchronous work done");
}).
catch(function(err) {
  console.log("Error:" + err);
}).
then(function() {
  console.log("Done")
});
Everything is working fine: The first then is executed after promiseFunc is resolved and the final then is executed last.
I think the spec expects me to return a new Promise or a value from the then, but there is nothing useful I can return.
Here are my questions:
- Does this 'pattern' for executing synchronous code after a promise is resolved make sense? Is it okay to return undefined from the 
thenblock? - What happens if someone decides to implement 
synchronousFunc1with a promise? This will break the order of execution. I think such a breaking change shouldn't be made. Instead anotherasynchronousFunc1should be implemented. Am I right? - What about my 
catch/thenimplementation? The finalthenshould be executed always. I think this will not work, if an exception is thrown in thecatchhandler. Are there alternatives? I know there is afinallyhandler in bluebird, but I want to use standard Promise features only.