googleapis / googleapis/google-cloud-node

database.run(...) hangs for a few seconds with invalid query

Open
#7,375 2 comments 0 reactions 1 assignee Assigned to @alkatrivedi View on GitHub
api: spanner library: spanner priority: p2 type: bug
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

`database.run(...)` hangs for a few seconds when an invalid query is passed.

#### Environment details

- OS: M1 Mac
- Node.js version: 20.7.0
- npm version: 10.1.0
- `@google-cloud/spanner` version: ^7.5.0
- spanner emulator version: 1.5.13
#### Steps to reproduce

I created minimum reproducible code: https://github.com/ikenox/nodejs-spanner-example/tree/hangs-with-invalid-query

```shell
git clone git@github.com:ikenox/nodejs-spanner-example.git
git checkout hangs-with-invalid-query
pnpm install
gcloud emulators spanner start &
SPANNER_EMULATOR_HOST=localhost:9010 pnpm exec ts-node src/main.ts
```

`main.ts` executes the code like below.

```ts
console.time('valid query');
await database.run('select 1');
console.timeEnd('valid query');

console.time('invalid query');
try{
await database.run('select aaa');
}catch(e){
console.log(e);
}
console.timeEnd('invalid query');
```

And the output is below:

```
valid query: 21.579ms
3 INVALID_ARGUMENT: Unrecognized name: aaa [at 1:8]
select aaa
^
invalid query: 7.406s
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.