https://eslint.org/docs/rules/no-return-await

이렇게 하지 말 것

async function f() {
	return await promiseFunc();
}

별 차이 없는데? 라고 생각했는데,

다시 읽어보니 콜스택에 유지 되느냐가 포인트인듯.

const makePromise = () =>
  new Promise((resolve) => {
    setTimeout(() => {
      resolve('done');
    }, 1000);
  });

const testReturnAwait = async () => {
  return await makePromise();
};

const noReturnAwait = async () => {
  return makePromise();
};

(async () => {
  console.log('start ' + new Date().getDate() + ':' + new Date().getSeconds());

  const arr1 = [];
  const arr2 = [];
  for (let i = 0; i < 10; i++) {
    arr1.push(testReturnAwait());
    arr2.push(noReturnAwait());
  }

  await Promise.all(arr1).then((responses) => console.log(responses));
  console.log('arr1 ' + new Date().getDate() + ':' + new Date().getSeconds());

  await Promise.all(arr2).then((responses) => console.log(responses));
  console.log('arr2 ' + new Date().getDate() + ':' + new Date().getSeconds());

  for (let i = 0; i < 10; i++) {
    console.log(await testReturnAwait());
  }
})();