Skip to content
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(web-console): align displayed timings with real fetch time #282

Merged
merged 3 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/web-console/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@questdb/web-console",
"version": "0.4.0",
"version": "0.4.1",
"license": "Apache-2.0",
"description": "QuestDB Console",
"files": [
Expand Down
30 changes: 16 additions & 14 deletions packages/web-console/src/utils/questdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export class Client {
Client.refreshTokenPending = false
return resolve(true)
}
}, 100)
}, 50)
})
}

Expand Down Expand Up @@ -343,23 +343,25 @@ export class Client {

this._controllers.push(controller)
let response: Response
const start = new Date()

if (this.tokenNeedsRefresh() && !Client.refreshTokenPending) {
await this.refreshAuthToken()
}

await new Promise((resolve) => {
const interval = setInterval(() => {
if (!Client.refreshTokenPending) {
clearInterval(interval)
return resolve(true)
}
}, 100)
})
if (Client.refreshTokenPending) {
await new Promise((resolve) => {
const interval = setInterval(() => {
if (!Client.refreshTokenPending) {
clearInterval(interval)
return resolve(true)
}
}, 50)
})
}

Client.numOfPendingQueries++

const start = new Date()
try {
response = await fetch(
`${this._host}/exec?${Client.encodeParams(payload)}`,
Expand All @@ -379,7 +381,7 @@ export class Client {

if (error instanceof DOMException) {
// eslint-disable-next-line prefer-promise-reject-errors
return await Promise.reject({
return Promise.reject({
...err,
error:
error.code === 20
Expand All @@ -391,7 +393,7 @@ export class Client {
eventBus.publish(EventType.MSG_CONNECTION_ERROR, genericErrorPayload)

// eslint-disable-next-line prefer-promise-reject-errors
return await Promise.reject(genericErrorPayload)
return Promise.reject(genericErrorPayload)
} finally {
const index = this._controllers.indexOf(controller)

Expand Down Expand Up @@ -425,7 +427,7 @@ export class Client {

if (data.error) {
// eslint-disable-next-line prefer-promise-reject-errors
return await Promise.reject({
return Promise.reject({
...data,
type: Type.ERROR,
})
Expand Down Expand Up @@ -471,7 +473,7 @@ export class Client {
}

// eslint-disable-next-line prefer-promise-reject-errors
return await Promise.reject(errorPayload)
return Promise.reject(errorPayload)
}

async showTables(): Promise<QueryResult<Table>> {
Expand Down