Nodejs-storage: "p-limit" dependency causes error on Google Cloud Functions

Created on 23 Jun 2020  路  1Comment  路  Source: googleapis/nodejs-storage

From version 5.1.0 to 5.1.1, the p-limit package dependency was updated from v2.x.x to v3.x.x

p-limit v3.x.x uses syntax that makes the package incompatible with environments running any JavaScript version older than ES2019. This sudden environment requirement is a major change, and a breaking change for platforms that rely on Google Cloud Functions which are limited to Node 8 and Node 10.

Environment details

  • OS: Windows 10
  • Node.js version: 8.17.0
  • npm version: 6.13.4
  • @google-cloud/storage version: 5.1.1

Steps to reproduce

  1. Run npm install on a package.json that requires @google-cloud/storage ^5.1.0
  2. Deploy code to Google Cloud Functions

It will throw this error:
Error: Error occurred while parsing your function triggers. C:\projects\...\functions\node_modules\p-limit\index.js:30 } catch {} ^ SyntaxError: Unexpected token {

storage question

Most helpful comment

This looks to be because that library is using try {} catch {} as opposed to try {} catch (e) {}. This is not an issue in our supported range of Node versions (>= 10), but is back in 8. Due to this, we won't be able to resolve this. If you can upgrade, that should resolve the issue. Alternatively, you can try using @google-cloud/storage versions prior to our 5.0 release, which is when Node 8 support was dropped.

>All comments

This looks to be because that library is using try {} catch {} as opposed to try {} catch (e) {}. This is not an issue in our supported range of Node versions (>= 10), but is back in 8. Due to this, we won't be able to resolve this. If you can upgrade, that should resolve the issue. Alternatively, you can try using @google-cloud/storage versions prior to our 5.0 release, which is when Node 8 support was dropped.

Was this page helpful?
0 / 5 - 0 ratings