title: Function execution took 60002 ms, finished with status: 'timeout'
body: <p>I have a Firebase cloud function that is loosely based on this example 
  <a href="https://github.com/firebase/functions-samples/tree/master/image-sharp" rel="nofollow noreferrer">https://github.com/firebase/functions-samples/tree/master/image-sharp</a></p>
  
  <p>Today, when deploying some small changes it gave me this warning</p>
  
  <pre><code>$ firebase deploy --only functions
  ⚠  functions: package.json indicates an outdated version of firebase-functions.
   Please upgrade using npm install --save firebase-functions@latest in your functions directory.
  </code></pre>
  
  <p>so I did the upgrade, which upgraded firebase-functions from ^1.0.3 to ^2.0.0</p>
  
  <p>since then have been getting this when running the function </p>
  
  <pre><code>Function execution took 60002 ms, finished with status: 'timeout'
  </code></pre>
  
  <p>instead of the usual</p>
  
  <pre><code>Function execution took 10 ms, finished with status: 'ok'
  </code></pre>
  
  <p>I started stripping down my function but even going down to bare bones it was still getting the error.</p>
  
  <p>I then started a new project used the example function as is and it behaves exactly the same way. With firebase-functions ^2.0.0 it gives the timeout error but with ^1.0.0 it works fine.</p>
  
  <p>Is this a known issue?</p>
  
  <p>Thanks</p>
  
  <p>Here is the example code</p>
  
  <pre><code>exports.generateThumbnail = functions.storage.object().onFinalize((object) =&gt; {
    const fileBucket = object.bucket; // The Storage bucket that contains the file.
    const filePath = object.name; // File path in the bucket.
    const contentType = object.contentType; // File content type.
  
    // Exit if this is triggered on a file that is not an image.
    if (!contentType.startsWith('image/')) {
      console.log('This is not an image.');
      return null;
    }
  
    // Get the file name.
    const fileName = path.basename(filePath);
    // Exit if the image is already a thumbnail.
    if (fileName.startsWith('thumb_')) {
      console.log('Already a Thumbnail.');
      return null;
    }
  
    // Download file from bucket.
    const bucket = gcs.bucket(fileBucket);
  
    const metadata = {
      contentType: contentType,
    };
    // We add a 'thumb_' prefix to thumbnails file name. That's where we'll upload the thumbnail.
    const thumbFileName = `thumb_${fileName}`;
    const thumbFilePath = path.join(path.dirname(filePath), thumbFileName);
    // Create write stream for uploading thumbnail
    const thumbnailUploadStream = bucket.file(thumbFilePath).createWriteStream({metadata});
  
    // Create Sharp pipeline for resizing the image and use pipe to read from bucket read stream
    const pipeline = sharp();
    pipeline
      .resize(THUMB_MAX_WIDTH, THUMB_MAX_HEIGHT)
      .max()
      .pipe(thumbnailUploadStream);
  
    bucket.file(filePath).createReadStream().pipe(pipeline);
  
    const streamAsPromise = new Promise((resolve, reject) =&gt;
      thumbnailUploadStream.on('finish', resolve).on('error', reject));
  
    return streamAsPromise.then(() =&gt; {
      console.log('Thumbnail created successfully');
      return null;
    });
  </code></pre>