'Create promise which never fulfils

How can I create a promise which will never fulfil? So that for example this will never reach console.log:

const res = await NEVER_FULLFILLING_PROMISE

console.log(res)


Solution 1:[1]

Just call new Promise and never call the first parameter in the callback.

(async () => {
  await new Promise(() => {});
  console.log('done');
})();

Another approach that fulfills the text of your question (but probably not the intent) would be to make the Promise reject, of course.

(async () => {
  await new Promise((_, reject) => reject());
  console.log('done');
})()
  .catch(() => {});

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1