From @MikeyBurkman on October 8, 2018 21:37
- VSCode Version: 1.28.0
- OS Version: OSX High Sierra
Steps to Reproduce:
- The code in the gif on https://code.visualstudio.com/updates/v1_28#_convert-to-async-function is actually wrong
- When doing
.then(fn1, fn2), the second arg fn2 should NOT be called if there's an error in fn1.
Sample code:
'use strict';
const promise = () => new Promise((res) => setTimeout(res, 500));
const fSync = function() {
return promise().then(
() => {
throw new Error('Failure!');
},
() => null
);
};
// This function was created by copying/pasting the above function, and applying the "convert to async function" helper
const fAsync = async function() {
try {
await promise();
throw new Error('Failure!');
} catch (e) {
return null;
}
};
fSync()
.then(() => console.log('SYNC Sucess?'))
.catch((err) => console.log('SYNC Got an error', err));
fAsync()
.then(() => console.log('ASYNC Sucess?'))
.catch((err) => console.log('ASYNC Got an error', err));
Expected output:
- Both should output "[A]SYNC Got an error Error: Failure!"
Actual output:
- SYNC Got an error Error: Failure!
- ASYNC Success?
Copied from original issue: microsoft/vscode#60201
From @MikeyBurkman on October 8, 2018 21:37
Steps to Reproduce:
.then(fn1, fn2), the second argfn2should NOT be called if there's an error infn1.Sample code:
Expected output:
Actual output:
Copied from original issue: microsoft/vscode#60201