Skip to content
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## v0.7.6-alpha

- Added an error to handle empty relation size of 0 bytes when reading arrow files

## v0.7.5-alpha

- Updated some dependencies.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@relationalai/rai-sdk-javascript",
"description": "RelationalAI SDK for JavaScript",
"version": "0.7.5-alpha",
"version": "0.7.6-alpha",
"author": {
"name": "RelationalAI",
"url": "https://relational.ai"
Expand Down
9 changes: 8 additions & 1 deletion src/api/transaction/transactionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { tableFromIPC } from 'apache-arrow';

import { MaxRelationSizeError } from '../../errors';
import { EmptyRelationSizeError, MaxRelationSizeError } from '../../errors';
import { MetadataInfo } from '../../proto/generated/message';
import { RelationId } from '../../proto/generated/schema';
import {
Expand Down Expand Up @@ -92,6 +92,13 @@ export async function readArrowFiles(files: TransactionAsyncFile[]) {
);
}

// The part that exceeds 2GB is returned as a blob of 0 bytes,
// all the remaining parts are empty as well in Windows’s Chrome,
// therefore, throwing the error here to avoid failures downstream
if (file.file.size === 0) {
throw new EmptyRelationSizeError(file.name);
}

const table = await tableFromIPC(file.file.stream());

results.push({
Expand Down
11 changes: 11 additions & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ export class MaxRelationSizeError extends Error {
}
}

export class EmptyRelationSizeError extends Error {
constructor(public relationId: string) {
const message = `Empty relation size of 0 bytes. Relation: ${relationId}`;

super(message);

this.name = 'EmptyRelationSizeError';
}
}

export class AbortError extends Error {
constructor(message?: string) {
super(message);
Expand All @@ -99,4 +109,5 @@ export type SdkError =
| ApiError
| TransactionError
| MaxRelationSizeError
| EmptyRelationSizeError
| Error;