@google-cloud/profiler
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -52,2 +52,14 @@ "use strict"; | ||
/** | ||
* @return the message of the response body, if that field exists. Otherwise, | ||
* returns the response status message. | ||
*/ | ||
function getResponseErrorMessage(response) { | ||
// tslint:disable-next-line: no-any | ||
const body = response.body; | ||
if (body && body.message && typeof body.message === 'string') { | ||
return body.message; | ||
} | ||
return response.statusMessage; | ||
} | ||
/** | ||
* @return number indicated by backoff if the response indicates a backoff and | ||
@@ -57,4 +69,2 @@ * that backoff is greater than 0. Otherwise returns undefined. | ||
function getServerResponseBackoff(response) { | ||
// tslint:disable-next-line: no-any | ||
const body = response.body; | ||
// The response currently does not have field containing the server-specified | ||
@@ -65,4 +75,5 @@ // backoff. As a workaround, response body's message is parsed to get the | ||
// body.error.details. | ||
if (body && body.message && typeof body.message === 'string') { | ||
return parseBackoffDuration(body.message); | ||
const message = getResponseErrorMessage(response); | ||
if (message) { | ||
return parseBackoffDuration(message); | ||
} | ||
@@ -134,4 +145,4 @@ return undefined; | ||
class BackoffResponseError extends Error { | ||
constructor(response, backoffMillis) { | ||
super(response.statusMessage); | ||
constructor(message, backoffMillis) { | ||
super(message); | ||
this.backoffMillis = backoffMillis; | ||
@@ -177,5 +188,6 @@ } | ||
if (response && isErrorResponseStatusCode(response.statusCode)) { | ||
const message = getResponseErrorMessage(response); | ||
const delayMillis = getServerResponseBackoff(response); | ||
if (delayMillis) { | ||
throw new BackoffResponseError(response, delayMillis); | ||
throw new BackoffResponseError(message, delayMillis); | ||
} | ||
@@ -182,0 +194,0 @@ throw new Error(response.statusMessage); |
{ | ||
"name": "@google-cloud/profiler", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Adds support for Stackdriver Profiler to node.js applications", | ||
@@ -29,12 +29,14 @@ "repository": "GoogleCloudPlatform/cloud-profiler-nodejs", | ||
"dependencies": { | ||
"@google-cloud/common": "^0.23.0", | ||
"@google-cloud/common": "^0.25.0", | ||
"@types/console-log-level": "^1.4.0", | ||
"@types/semver": "^5.5.0", | ||
"bindings": "^1.2.1", | ||
"console-log-level": "^1.4.0", | ||
"delay": "^3.1.0", | ||
"delay": "^4.0.1", | ||
"extend": "^3.0.1", | ||
"gcp-metadata": "^0.7.0", | ||
"gcp-metadata": "^0.8.0", | ||
"nan": "^2.8.0", | ||
"parse-duration": "^0.1.1", | ||
"pify": "^4.0.0", | ||
"pretty-ms": "^3.1.0", | ||
"pretty-ms": "^4.0.0", | ||
"protobufjs": "~6.8.6", | ||
@@ -45,3 +47,2 @@ "semver": "^5.5.0", | ||
"devDependencies": { | ||
"@types/console-log-level": "^1.4.0", | ||
"@types/extend": "^3.0.0", | ||
@@ -55,3 +56,2 @@ "@types/long": "^4.0.0", | ||
"@types/request": "^2.47.1", | ||
"@types/semver": "^5.5.0", | ||
"@types/sinon": "^5.0.1", | ||
@@ -64,3 +64,3 @@ "codecov": "^3.0.0", | ||
"mocha": "^5.0.0", | ||
"nock": "^9.0.22", | ||
"nock": "^10.0.0", | ||
"nyc": "^13.0.0", | ||
@@ -70,3 +70,3 @@ "sinon": "^6.0.0", | ||
"ts-mockito": "^2.2.5", | ||
"typescript": "~3.0.0" | ||
"typescript": "~3.1.0" | ||
}, | ||
@@ -73,0 +73,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1168956
21
22530
15
+ Added@types/semver@^5.5.0
+ Added@google-cloud/common@0.25.3(transitive)
+ Added@types/console-log-level@1.4.5(transitive)
+ Added@types/semver@5.5.0(transitive)
+ Addedbignumber.js@9.1.2(transitive)
+ Addeddelay@4.4.1(transitive)
+ Addedgcp-metadata@0.8.0(transitive)
+ Addedgoogle-auth-library@2.0.2(transitive)
+ Addedjson-bigint@0.3.1(transitive)
+ Addedlru-cache@5.1.1(transitive)
+ Addedparse-ms@2.1.0(transitive)
+ Addedpretty-ms@4.0.0(transitive)
+ Addedyallist@3.1.1(transitive)
- Removed@google-cloud/common@0.23.0(transitive)
- Removeddelay@3.1.0(transitive)
- Removedgcp-metadata@0.6.3(transitive)
- Removedgoogle-auth-library@1.6.1(transitive)
- Removedlodash.isstring@4.0.1(transitive)
- Removedlru-cache@4.1.5(transitive)
- Removedparse-ms@1.0.1(transitive)
- Removedpretty-ms@3.2.0(transitive)
- Removedpseudomap@1.0.2(transitive)
- Removedyallist@2.1.2(transitive)
Updated@google-cloud/common@^0.25.0
Updateddelay@^4.0.1
Updatedgcp-metadata@^0.8.0
Updatedpretty-ms@^4.0.0