-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Verify the response string length overflow and throw a specific error (…
- Loading branch information
Showing
3 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
packages/client-common/__tests__/integration/invalid_string_length.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { ClickHouseClient } from '@clickhouse/client-common' | ||
import { createTestClient } from '@test/utils' | ||
|
||
// See https://github.com/ClickHouse/clickhouse-js/issues/106 | ||
describe('invalid string length', () => { | ||
let client: ClickHouseClient | ||
afterEach(async () => { | ||
await client.close() | ||
}) | ||
beforeEach(async () => { | ||
client = createTestClient() | ||
}) | ||
|
||
const errorMessageMatcher = jasmine.stringContaining( | ||
'consider limiting the amount of requested rows', | ||
) | ||
|
||
// The client will buffer the entire response in a string for non-streamable formats. | ||
// A large amount of system.numbers selected should overflow the max allowed allocation size for a string. | ||
it('should fail with a specific error when the response string is too large - json() call', async () => { | ||
const rs = await client.query({ | ||
query: 'SELECT number FROM numbers(50000000)', | ||
format: 'JSON', | ||
}) | ||
await expectAsync(rs.json()).toBeRejectedWith( | ||
jasmine.objectContaining({ | ||
message: errorMessageMatcher, | ||
}), | ||
) | ||
expect().nothing() | ||
}) | ||
|
||
it('should fail with a specific error when the response string is too large - text() call', async () => { | ||
const rs = await client.query({ | ||
query: 'SELECT number FROM numbers(50000000)', | ||
format: 'JSON', | ||
}) | ||
await expectAsync(rs.text()).toBeRejectedWith( | ||
jasmine.objectContaining({ | ||
message: errorMessageMatcher, | ||
}), | ||
) | ||
expect().nothing() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters