Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add maxResultSize limit #1

Merged
merged 1 commit into from
Mar 26, 2025
Merged

Conversation

avallete
Copy link
Member

@avallete avallete commented Mar 25, 2025

What kind of change does this PR introduce?

  • Add a new parameter to the connection allowing to cancel the pulling of a query rows once the pulled data exceed some max limit. Avoiding OOM of the program, and allowing to handle the error on the caller side.

Main PR can be found here: brianc#3406

Comment on lines +117 to +140
// Check the result size if maxResultSize is configured
if (self._maxResultSize) {
// Calculate result size (rough approximation)
let resultSize = 0

// For multiple result sets
if (results.length > 1) {
for (let i = 0; i < rows.length; i++) {
resultSize += self._calculateResultSize(rows[i])
}
} else if (rows.length > 0) {
resultSize = self._calculateResultSize(rows)
}

// If the size limit is exceeded, generate an error
if (resultSize > self._maxResultSize) {
const error = new Error('Query result size exceeded the configured limit')
error.code = 'RESULT_SIZE_EXCEEDED'
error.resultSize = resultSize
error.maxResultSize = self._maxResultSize
return self.handleError(error)
}
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note

The native code shouldn't really be called in our case, it's there because it needs to be handled to work with the main repo tests.

@avallete avallete merged commit e81759c into master Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants