-
Notifications
You must be signed in to change notification settings - Fork 103
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
fix: unhandled exception error catch #2091
fix: unhandled exception error catch #2091
Conversation
test/spanner.ts
Outdated
.filter(val => (val as v1.ExecuteSqlRequest).sql) | ||
.map(req => req as v1.ExecuteSqlRequest); | ||
|
||
assert.strictEqual(requests.length, 6); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are there 6 requests ? There should be 4 requests.
9db3dd8
to
e1b3784
Compare
e1b3784
to
d104bc8
Compare
57f1fc6
to
8f69542
Compare
@@ -1219,8 +1227,16 @@ export class Snapshot extends EventEmitter { | |||
this._update(response.metadata!.transaction); | |||
} | |||
}) | |||
.on('error', () => { | |||
if (!this.id && this._useInRunner) { | |||
.on('error', err => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a different refactor PR: It seems that runStream
and createReadStream
have a lot of duplicated code. Could we combine more of those?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
const database = newTestDatabase(); | ||
await database.runTransactionAsync(async tx => { | ||
try { | ||
await Promise.all([tx!.run(selectSql), tx!.run(invalidSql)]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we already have a test for the same with these requests in the other order? That is; with the invalid SQL first?
If not, can we add that as well, and verify that:
- The initial call to ExecuteStreamingSql fails, which also means that there is no transaction ID that is returned.
- The transaction is retried with an explicit BeginTransaction and then the invalid SQL + working SQL statement.
- Catch the error from the invalid SQL statement.
- Commit the transaction (even though one of the statements failed).
- The result should be (I think):
ExecuteSql(transaction{begin: {readwrite=true}})
BeginTransaction(readwrite=true)
ExecuteSql(transaction{id:...})
ExecuteSql(transaction{id:...})
Commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be doing this in a separate PR
🤖 I have created a release *beep* *boop* --- ## [7.13.0](https://togithub.com/googleapis/nodejs-spanner/compare/v7.12.0...v7.13.0) (2024-08-09) ### Features * **spanner:** Add support for Cloud Spanner Incremental Backups ([#2085](https://togithub.com/googleapis/nodejs-spanner/issues/2085)) ([33b9645](https://togithub.com/googleapis/nodejs-spanner/commit/33b9645d6096e0d77d30fab6aadf5d92da973a67)) ### Bug Fixes * Unhandled exception error catch ([#2091](https://togithub.com/googleapis/nodejs-spanner/issues/2091)) ([e277752](https://togithub.com/googleapis/nodejs-spanner/commit/e277752fad961908e37e37d88d7b6a61d61a078e)) --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
fixes: #1972