Skip to content

Commit 10276aa

Browse files
authored
fix empty arrow part (#103)
* fix empty arrow part * add await * fix add empty relation size error * added comment * added changelog and updated version * add space * fix grammar
1 parent ac289ac commit 10276aa

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## v0.7.6-alpha
4+
5+
- Added an error to handle empty relation size of 0 bytes when reading arrow files
6+
37
## v0.7.5-alpha
48

59
- Updated some dependencies.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@relationalai/rai-sdk-javascript",
33
"description": "RelationalAI SDK for JavaScript",
4-
"version": "0.7.5-alpha",
4+
"version": "0.7.6-alpha",
55
"author": {
66
"name": "RelationalAI",
77
"url": "https://relational.ai"

src/api/transaction/transactionUtils.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { tableFromIPC } from 'apache-arrow';
1818

19-
import { MaxRelationSizeError } from '../../errors';
19+
import { EmptyRelationSizeError, MaxRelationSizeError } from '../../errors';
2020
import { MetadataInfo } from '../../proto/generated/message';
2121
import { RelationId } from '../../proto/generated/schema';
2222
import {
@@ -92,6 +92,13 @@ export async function readArrowFiles(files: TransactionAsyncFile[]) {
9292
);
9393
}
9494

95+
// The part that exceeds 2GB is returned as a blob of 0 bytes,
96+
// all the remaining parts are empty as well in Windows’s Chrome,
97+
// therefore, throwing the error here to avoid failures downstream
98+
if (file.file.size === 0) {
99+
throw new EmptyRelationSizeError(file.name);
100+
}
101+
95102
const table = await tableFromIPC(file.file.stream());
96103

97104
results.push({

src/errors.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ export class MaxRelationSizeError extends Error {
8282
}
8383
}
8484

85+
export class EmptyRelationSizeError extends Error {
86+
constructor(public relationId: string) {
87+
const message = `Empty relation size of 0 bytes. Relation: ${relationId}`;
88+
89+
super(message);
90+
91+
this.name = 'EmptyRelationSizeError';
92+
}
93+
}
94+
8595
export class AbortError extends Error {
8696
constructor(message?: string) {
8797
super(message);
@@ -99,4 +109,5 @@ export type SdkError =
99109
| ApiError
100110
| TransactionError
101111
| MaxRelationSizeError
112+
| EmptyRelationSizeError
102113
| Error;

0 commit comments

Comments
 (0)