0

my functions package.json

...
"dependencies": {
    "firebase-admin": "~5.13.0",
    "firebase-functions": "^2.0.0",
    "puppeteer": "^1.6.2"
},
"engines": {
    "node": "8"
}

my old non async functions get deployed. But not my new async one:

exports.screenshot = async  (req, res) => {
  const url = "https://google.de"; // req.query.url;

  if (!url) {
    return res.send('Please provide URL as GET parameter, for example: <a href="?url=https://example.com">?url=https://example.com</a>');
  }

  const browser = await puppeteer.launch({
    args: ["--no-sandbox"]
  });
  const page = await browser.newPage();
  await page.goto(url);
  const imageBuffer = await page.screenshot();
  await browser.close();

  res.set("Content-Type", "image/png");
  res.send(imageBuffer);
};

when running: firebase deploy --only functions:screenshot I get the error:

The following functions are found in your project but do not exist in your local source code:
        screenshot(us-central1)

what can I do?

6
  • Async/Await has been supported since Node 7.6. Are you linting the script? Commented Aug 13, 2018 at 14:33
  • linting gives no erros. Problem is that it is not detected by the deploy script Commented Aug 13, 2018 at 14:44
  • Please edit the question to show more specifically what the error is. Is there output from the command line that describes the problem? Commented Aug 13, 2018 at 14:47
  • I get no error. The async function isn't deployed (recognized?) Commented Aug 13, 2018 at 14:50
  • are you issuing Module.exports anywhere else in your node script? If so, that overrides your individual export Commented Aug 13, 2018 at 15:06

1 Answer 1

1
exports.screenshot = functions.https.onRequest(async (req, res) => {
...
});

did it for me

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.