Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: throw for versions of Node.js older than v10.0.0 #748

Merged
merged 4 commits into from
Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [8, 10, 12, 13]
node: [10, 12, 13]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
Expand Down
19 changes: 10 additions & 9 deletions src/grpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,20 @@ export class GrpcClient {
this.auth = options.auth || new GoogleAuth(options);
this.fallback = false;

const minimumVersion = '10.0.0';
if (semver.lt(process.version, minimumVersion)) {
const errorMessage =
`Node.js v${minimumVersion} is a minimum requirement. To learn about legacy version support visit: ` +
'https://github.com/googleapis/google-cloud-node#supported-nodejs-versions';
throw new Error(errorMessage);
}

if ('grpc' in options) {
this.grpc = options.grpc!;
this.grpcVersion = '';
} else {
if (semver.gte(process.version, '8.13.0')) {
this.grpc = grpc;
this.grpcVersion = require('@grpc/grpc-js/package.json').version;
} else {
const errorMessage =
'To use @grpc/grpc-js you must run your code on Node.js v8.13.0 or newer. Please see README if you need to use an older version. ' +
'https://github.com/googleapis/gax-nodejs/blob/master/README.md';
throw new Error(errorMessage);
}
this.grpc = grpc;
this.grpcVersion = require('@grpc/grpc-js/package.json').version;
}
}

Expand Down