From 41f1b8e803e7fe2092b2442eb64c5de8a1fd1175 Mon Sep 17 00:00:00 2001 From: Sciator <39964450+Sciator@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:54:57 +0100 Subject: [PATCH] feat: queryTimeout --- CHANGELOG.md | 10 +++++++++- packages/client/src/impl/QueryApiImpl.ts | 4 ++-- packages/client/src/options.ts | 6 ++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1956331..ce6852c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ -## 0.5.0 [unreleased] +## 0.4.1 [unreleased] + +### Feature + +1. Query timeout + +### Bugfix + +1. [#164](https://github.com/InfluxCommunity/influxdb3-js/issues/164): Default query timeout ## 0.4.0 [2023-11-03] diff --git a/packages/client/src/impl/QueryApiImpl.ts b/packages/client/src/impl/QueryApiImpl.ts index cd2927c9..152db9fb 100644 --- a/packages/client/src/impl/QueryApiImpl.ts +++ b/packages/client/src/impl/QueryApiImpl.ts @@ -41,8 +41,8 @@ export default class QueryApiImpl implements QueryApi { const token = this._options.token if (token) meta['authorization'] = `Bearer ${token}` - - const options: RpcOptions = {meta} + const timeout = this._options.queryTimeout + const options: RpcOptions = {meta, timeout} const flightDataStream = client.doGet(ticket, options) diff --git a/packages/client/src/options.ts b/packages/client/src/options.ts index f713ce5e..ab54b2a0 100644 --- a/packages/client/src/options.ts +++ b/packages/client/src/options.ts @@ -13,6 +13,11 @@ export interface ConnectionOptions { * @defaultValue 10000 */ timeout?: number + /** + * stream timeout for query (grpc timeout) + * @defaultValue 60000 + */ + queryTimeout?: number /** * default database for write query if not present as argument. */ @@ -43,6 +48,7 @@ export interface ConnectionOptions { /** default connection options */ export const DEFAULT_ConnectionOptions: Partial = { timeout: 10000, + queryTimeout: 60000, } /**