Skip to content

Instantly share code, notes, and snippets.

@cjbj
Created July 21, 2021 23:42
Show Gist options
  • Save cjbj/f778f9a851ce800f53a4effb5bce1ae2 to your computer and use it in GitHub Desktop.
Save cjbj/f778f9a851ce800f53a4effb5bce1ae2 to your computer and use it in GitHub Desktop.
Patch for node-oracledb 5.2 issue #1391
diff --git a/lib/queryStream.js b/lib/queryStream.js
index 08ddc72..09efc99 100644
--- a/lib/queryStream.js
+++ b/lib/queryStream.js
@@ -89,11 +89,6 @@ class QueryStream extends Readable {
this._fetching = true;
this._resultSet._allowGetRowCall = true;
const row = await this._resultSet.getRow();
- this._fetching = false;
- if (!this._resultSet) {
- this.emit('_doneFetching');
- return;
- }
if (row) {
this.push(row);
} else {
@@ -101,6 +96,13 @@ class QueryStream extends Readable {
}
} catch (err) {
this.destroy(err);
+ } finally {
+ this._fetching = false;
+ if (this.resultSet) {
+ this._resultSet._allowGetRowCall = false;
+ } else {
+ this.emit('_doneFetching');
+ }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment