Closed abawany closed 8 years ago
On capturing a stack trace at the offending line, it appears that the function above is invoked thrice. The first invocation works but the next two fail. The code that invokes the above function is as follows (line 149 of the same file):
function parseHttpRespMessage(httpRespMessage) {
var parsedHttpRespMessage = {
resp: httpRespMessage
};
if (httpRespMessage.statusCode < 200 || httpRespMessage.statusCode > 299) {
// Unknown error. Format according to ApiError standard.
parsedHttpRespMessage.err = new util.ApiError({ // this is line 149
errors: [],
code: httpRespMessage.statusCode,
message: httpRespMessage.statusMessage,
response: httpRespMessage
});
}
return parsedHttpRespMessage;
}
Can you show the code you're using that access our library?
Sure. I was previously using gcloud@0.37.0
and hadn't noticed these issues. Moving to google-cloud
(starting with 0.40.0 and now at 0.41.2) shows these issues.
var gc = require('google-cloud') ({ projectId: 'something' });
var gsInst = gc.storage({ projectId: 'something' });
var bucket = gsInst.bucket('bucket');
var destFile = bucket.file(fromFile);
var strm = destFile.createReadStream({validation: 'crc32c'});
strm
.on('error', function(e) {
log.inst.error({e: e.stack});
return cb(e);
})
.pipe(res)
.on('response', function(r) { log.inst.debug({r: r}); })
.on('end', function() {
log.inst.debug({end: true});
return res.send(200);
}
);
I haven't been able to reproduce with the following code using @google-cloud/storage
@0.2.0 (included in google-cloud
> 41.0):
{
"name": "@google-cloud/gissue-1654",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@google-cloud/storage": "^0.2.0"
}
}
var storage = require('@google-cloud/storage')({ authInfo })
var stream = require('stream')
var file = storage.bucket('stephen-has-a-new-bucket').file('non-existent-file')
file.createReadStream({ validation: 'crc32c' })
.on('error', function(e) {
console.log('error', e)
})
.on('data', function() {})
Would you mind trying it in this format, which doesn't have other dependencies?
The code is behaving as expected. The issue that caused the uce was due to passing the error object returned by this call to gcloud logging instead of error.stack. Here was the uce for reference - I will close this issue.
{ t: 'object',
x:
TypeError: obj.hasOwnProperty is not a function
at Function.GrpcService.objToStruct_ (/tmp/node_modules/google-cloud/node_modules/@google-cloud/common/src/grpc-service.js:669:13)
at Function.GrpcService.encodeValue_ (/tmp/node_modules/google-cloud/node_modules/@google-cloud/common/src/grpc-service.js:506:32)
at Function.GrpcService.objToStruct_ (/tmp/node_modules/google-cloud/node_modules/@google-cloud/common/src/grpc-service.js:676:50)
at Function.GrpcService.encodeValue_ (/tmp/node_modules/google-cloud/node_modules/@google-cloud/common/src/grpc-service.js:506:32)
at Function.GrpcService.objToStruct_ (/tmp/node_modules/google-cloud/node_modules/@google-cloud/common/src/grpc-service.js:676:50)
at Function.GrpcService.encodeValue_ (/tmp/node_modules/google-cloud/node_modules/@google-cloud/common/src/grpc-service.js:506:32)
at Function.GrpcService.objToStruct_ (/tmp/node_modules/google-cloud/node_modules/@google-cloud/common/src/grpc-service.js:676:50)
at Function.GrpcService.encodeValue_ (/tmp/node_modules/google-cloud/node_modules/@google-cloud/common/src/grpc-service.js:506:32)
at Function.GrpcService.objToStruct_ (/tmp/node_modules/google-cloud/node_modules/@google-cloud/common/src/grpc-service.js:676:50)
at Function.GrpcService.encodeValue_ (/tmp/node_modules/google-cloud/node_modules/@google-cloud/common/src/grpc-service.js:506:32),
e: '{}' }
Phew, glad it worked out!
@JustinBeckwith and @stephenplusplus not sure why this 4 year old bug was re-assigned to me but it is closed anyways so no harm no foul, I guess ?
When Google Storage is used to access a file that does not exist, the following uncaught exception is generated by the package:
Going to line 107 of the offending file shows this:
(EDIT: alleged remedy was not a solution either). ApiError is defined above this code as
var ApiError = ...
.Environment details
Steps to reproduce
google-cloud
Making sure to follow these steps will guarantee the quickest resolution possible.
Thanks!