Skip to content

Commit

Permalink
Merge pull request #223 from tonlabs/0.44.4-rc
Browse files Browse the repository at this point in the history
 Tackle with errors
  • Loading branch information
d3p authored Oct 26, 2021
2 parents 02ffb8a + 7a09c2e commit d99e9b5
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 32 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file.

## [0.44.4] - 2021-10-25

### Fix

- diagnostic timeout added to statsD reporting
- "Cannot read property 'length' of null" error

## [0.44.3] - 2021-10-25

### Fix
Expand Down
2 changes: 1 addition & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ton-q-server",
"version": "0.44.3",
"version": "0.44.4",
"description": "TON Q Server – realtime queries over TON blockchain.",
"main": "index.js",
"repository": "[email protected]:tonlabs/ton-q-server.git",
Expand Down
10 changes: 5 additions & 5 deletions src/server/data/collection-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ export class QCollectionQuery {
collectionName: string,
collectionDocType: QType,
args: {
filter?: CollectionFilter,
orderBy?: OrderBy[],
limit?: number,
timeout?: number,
operationId?: string,
filter?: CollectionFilter | null,
orderBy?: OrderBy[] | null,
limit?: number | null,
timeout?: number | null,
operationId?: string | null,
},
selectionSet: SelectionSetNode | undefined,
accessRights: AccessRights,
Expand Down
47 changes: 25 additions & 22 deletions src/server/data/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ import { QJoinQuery } from "./collection-joins";
const INDEXES_REFRESH_INTERVAL = 60 * 60 * 1000; // 60 minutes

export type AggregationArgs = {
filter: CollectionFilter,
fields?: FieldAggregation[],
accessKey?: string,
filter?: CollectionFilter | null,
fields?: FieldAggregation[] | null,
accessKey?: string | null,
};

export type QCollectionOptions = {
Expand Down Expand Up @@ -237,7 +237,7 @@ export class QDataCollection {
return {
subscribe: async (
_: unknown,
args: AccessArgs & { filter: CollectionFilter },
args: AccessArgs & { filter: CollectionFilter | null },
request: QRequestContext,
info: { operation: { selectionSet: SelectionSetNode } },
) => {
Expand Down Expand Up @@ -328,8 +328,8 @@ export class QDataCollection {
return async (
_parent: unknown,
args: {
filter?: CollectionFilter,
orderBy?: OrderBy[],
filter?: CollectionFilter | null,
orderBy?: OrderBy[] | null,
},
) => {
await this.checkRefreshInfo();
Expand All @@ -354,17 +354,20 @@ export class QDataCollection {
async optimizeSortedQueryWithSingleResult(
args: {
accessKey?: string | null,
filter?: CollectionFilter,
orderBy?: OrderBy[],
limit?: number,
timeout?: number,
operationId?: string,
filter?: CollectionFilter | null,
orderBy?: OrderBy[] | null,
limit?: number | null,
timeout?: number | null,
operationId?: string | null,
},
accessRights: AccessRights,
request: QRequestContext,
traceSpan: QTraceSpan,
) {
if (args.orderBy === undefined || args.orderBy.length === 0) {
if (!args.orderBy || args.orderBy.length === 0) {
return;
}
if (!args.orderBy || args.orderBy.length === 0) {
return;
}
if (args.limit === undefined || args.limit !== 1) {
Expand Down Expand Up @@ -411,11 +414,11 @@ export class QDataCollection {
query: QCollectionQuery,
args: {
accessKey?: string | null,
filter?: CollectionFilter,
orderBy?: OrderBy[],
limit?: number,
timeout?: number,
operationId?: string,
filter?: CollectionFilter | null,
orderBy?: OrderBy[] | null,
limit?: number | null,
timeout?: number | null,
operationId?: string | null,
},
selection: SelectionSetNode | undefined,
request: QRequestContext,
Expand Down Expand Up @@ -493,11 +496,11 @@ export class QDataCollection {
_parent: unknown,
args: {
accessKey?: string | null,
filter?: CollectionFilter,
orderBy?: OrderBy[],
limit?: number,
timeout?: number,
operationId?: string,
filter?: CollectionFilter | null,
orderBy?: OrderBy[] | null,
limit?: number | null,
timeout?: number | null,
operationId?: string | null,
},
request: QRequestContext,
selection: {
Expand Down
4 changes: 2 additions & 2 deletions src/server/graphql/counterparties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {required} from "../utils";

type CounterpartiesArgs = {
accessKey?: string | null,
first?: number,
after?: string,
first?: number | null,
after?: string | null,
account: string,
};

Expand Down
12 changes: 11 additions & 1 deletion src/server/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ export class QStats implements IStats {

withImpl(f: (impl: IStatsImpl, callback: StatsCallback) => void): Promise<void> {
return new Promise((resolve) => {
const timeoutTimer = setTimeout(() => {
// TODO: Replace `logStatsError` with `this.dropImpl` in next line
// and reduce timeout
// when (and if) this error will be observed in the log.
logStatsError({ name: "", message: "timeouted (should be impossible, report to Q Server authors)"});
resolve();
}, 10000); // 10 seconds should be more than enough

try {
if (this.resetTime > 0) {
const now = Date.now();
Expand All @@ -110,10 +118,12 @@ export class QStats implements IStats {
if (error !== undefined && error !== null) {
this.dropImpl(error);
}
clearTimeout(timeoutTimer);
resolve();
});
} catch (error) {
this.dropImpl(error);
clearTimeout(timeoutTimer);
this.dropImpl(error as Error);
resolve();
}
});
Expand Down

0 comments on commit d99e9b5

Please sign in to comment.