Firebase Async / Await DeprecationWarning: Необработанные отказы от обещаний устарели - PullRequest
0 голосов
/ 01 мая 2019

Я пытаюсь создать простое соединение с моей базой данных Firebase Realtime-Database, используя функции с Async / Await для сокращения кода, и даже если я обертываю код с помощью try / catch, он все равно выдает следующую ошибку.

exports.createBlogPost = functions.https.onRequest(async (req, res) => {
  try {
    cors(req, res, () => { });
    const response = req.body;
    response.createDate = new Date();
    const snapshot = await admin.database().ref(BLOG_POSTS).push(response);
    console.log("SNAP", snapshot.getKey());
    response.id = snapshot.getKey();
    res.send(response);
  } catch (e) {
    res.status(500).send(e);
  }
});

Создает экземпляр в базе данных, но я получаю следующее предупреждение:

info: SNAP -LdnpewpwEz9EOkAA05H

error: (node:13656) UnhandledPromiseRejec: Unhandled promise rejections are deprecated. 
In the future, promise rejectiontionWarning: Unhandled promise rejection. Node.js process with a non-zero exit code. 
This error originated either by throwingon completed successfully inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)(node:13656) 
[DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. 
In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.info: Execution took 1035 ms, user function completed successfullyerror: Function worker killed by signal: SIGTERM

...