-
Notifications
You must be signed in to change notification settings - Fork 108
Closed
Labels
🚨This issue needs some love.This issue needs some love.api: datastoreIssues related to the googleapis/nodejs-datastore API.Issues related to the googleapis/nodejs-datastore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- OS: macOS Mojave
- Node.js version: v10.16.0
- npm version: 6.9.0
@google-cloud/datastoreversion: 4.2.0- Built version
Steps to reproduce
If we give undefined to a query filter, an uncatchable error is thrown: Error: Unsupported field value, undefined, was provided., and program crashes.
Problem occurs only in built version, because Typescript doesn't compile with this scenario:
let query = new FakeQuery();
query.namespace = 'namespace';
query = extend(true, new FakeQuery(), query);
query.filter('myfield', undefined); // => error TS2345: Argument of type 'undefined' is not assignable to parameter of type '{}'.To be able to catch the error, the library instead of doing:
// src/request/ts: l.788
stream.once('reading', () => {
makeRequest(query);
});could do this:
// src/request/ts: l.788
stream.once('reading', () => {
try {
makeRequest(query);
} catch (err) {
stream.emit('error', err);
}
});For Typescript it doesn't change anything. But for the JS built version, the error becomes catchable.
I can send a pull request if you want.
Metadata
Metadata
Assignees
Labels
🚨This issue needs some love.This issue needs some love.api: datastoreIssues related to the googleapis/nodejs-datastore API.Issues related to the googleapis/nodejs-datastore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.