Skip to content

Commit 3071e5d

Browse files
committed
fix: temporary last chunk fix
1 parent 2f7e745 commit 3071e5d

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

src/components/QueryResultTable/QueryResultTable.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React from 'react';
33
import DataTable from '@gravity-ui/react-data-table';
44
import type {Column, Settings} from '@gravity-ui/react-data-table';
55

6+
import {INDEX_COLUMN} from '../../store/reducers/query/query';
67
import type {ColumnType, KeyValueRow} from '../../types/api/query';
78
import {cn} from '../../utils/cn';
89
import {DEFAULT_TABLE_SETTINGS} from '../../utils/constants';
@@ -21,7 +22,6 @@ const TABLE_SETTINGS: Settings = {
2122
...DEFAULT_TABLE_SETTINGS,
2223
stripedRows: true,
2324
sortable: false,
24-
displayIndices: true,
2525
};
2626

2727
export const b = cn('ydb-query-result-table');
@@ -99,11 +99,16 @@ export const QueryResultTable = (props: QueryResultTableProps) => {
9999
return <div className={b('message')}>{i18n('empty')}</div>;
100100
}
101101

102+
const settings = {
103+
...TABLE_SETTINGS,
104+
displayIndices: columns.filter(({name}) => INDEX_COLUMN.name === name).length === 0,
105+
};
106+
102107
return (
103108
<ResizeableDataTable
104109
data={data}
105110
columns={columns}
106-
settings={TABLE_SETTINGS}
111+
settings={settings}
107112
// prevent accessing row.id in case it is present but is not the PK (i.e. may repeat)
108113
rowKey={getRowIndex}
109114
visibleRowIndex={getVisibleRowIndex}

src/components/ResizeableDataTable/ResizeableDataTable.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type {DataTableProps, Settings} from '@gravity-ui/react-data-table';
22
import DataTable, {updateColumnsWidth} from '@gravity-ui/react-data-table';
33

4-
import {INDEX_COLUMN} from '../../store/reducers/query/query';
54
import {cn} from '../../utils/cn';
65
import {useTableResize} from '../../utils/hooks/useTableResize';
76

@@ -28,7 +27,6 @@ export function ResizeableDataTable<T>({
2827
const newSettings: Settings = {
2928
...settings,
3029
defaultResizeable: true,
31-
displayIndices: columns.filter(({name}) => INDEX_COLUMN.name === name).length === 0,
3230
};
3331

3432
return (

src/services/parsers/parseMultipart.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ interface MultipartResult {
88
const CRLF = '\r\n';
99
const HEADER_VALUE_DELIMITER = ': ';
1010

11+
// temporary spike for backend problems
12+
const BACKEND_LAST_CHUNK_BOUNDARY = '--boundary--';
13+
1114
function getContentHeadersData(data: string, startPos: number): [number, number] {
1215
let contentLength = 0;
1316
let pos = startPos;
@@ -80,25 +83,27 @@ export function parseMultipart({
8083
}
8184

8285
// Check if we have enough data for the content
83-
const contentEnd = contentStart + contentLength;
86+
let contentEnd = contentStart + contentLength;
8487
if (contentEnd > data.length) {
85-
// Content is incomplete
86-
pos = lastProcessedLength;
87-
break;
88+
// last chunk has error with --boundary-- in content length
89+
// eslint-disable-next-line no-negated-condition
90+
if (data.indexOf(BACKEND_LAST_CHUNK_BOUNDARY, contentStart) !== -1) {
91+
contentEnd = data.indexOf(BACKEND_LAST_CHUNK_BOUNDARY, contentStart) - 2;
92+
} else {
93+
// Content is incomplete
94+
pos = lastProcessedLength;
95+
break;
96+
}
8897
}
8998

9099
// Extract content
91-
let content = data.slice(contentStart, contentEnd);
100+
const content = data.slice(contentStart, contentEnd);
92101

93102
// Try to parse JSON content
94103
try {
95104
const parsedChunk = JSON.parse(content) as StreamingChunk;
96105
chunks.push(parsedChunk);
97106
} catch {
98-
// try parse last chunk (has error with --boundary-- in content length)
99-
content = data.slice(contentStart, contentEnd - '--boundary--'.length);
100-
const parsedChunk = JSON.parse(content) as StreamingChunk;
101-
chunks.push(parsedChunk);
102107
// Invalid JSON, skip this chunk
103108
}
104109

0 commit comments

Comments
 (0)