You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
While streaming data, pausing the stream results in "TypeError: request.pause is not a function" #799
I want to stream 1 million+ rows from mssql database to another database. To deal with the Backpressure (mssql database is way faster) I want to pause the stream until the data at hand is processed (and prevent Memory exhaustion).
However when using the example from this repository I keep running into this error: "TypeError: request.pause is not a function"
Code snippet
const sql = require('mssql');
const config = {
user: 'user-name',
password: 'password',
server: 'hostname,
database: 'databasename',
options: {
encrypt: true // Use this if you're on Windows Azure
}
}
sql.connect(config, err => {
if (err) {
// @todo log error
}
else{
var rowsToProcess = [];
var request = new sql.Request();
request.stream = true;
request.query('select * from table_name')
request.on('row', row => {
rowsToProcess.push(row);
if (rowsToProcess.length > 100) {
request.pause();
processRows();
}
});
request.on('done', () => {
processRows();
sql.close();
})
function processRows() {
rowsToProcess = [];
request.resume();
}
}
});
Running code snippet results in following error:
TypeError: request.pause is not a function
at Request.request.on.row (/Users/folder/test.js:26:17)
at Request.emit (events.js:182:13)
at Request.req.on.columns (/Users/folder/node_modules/mssql/lib/tedious.js:780:20)
at Request.emit (events.js:182:13)
at Parser.<anonymous> (/Users/folder/node_modules/mssql/node_modules/tedious/lib/connection.js:744:28)
at Parser.emit (events.js:182:13)
at Parser.<anonymous> (/Users/folder/node_modules/mssql/node_modules/tedious/lib/token/token-stream-parser.js:54:15)
at Parser.emit (events.js:182:13)
at addChunk (/Users/folder/node_modules/readable-stream/lib/_stream_readable.js:291:12)
at readableAddChunk (/Users/folder/node_modules/readable-stream/lib/_stream_readable.js:278:11)
changed the title [-]While streaming data, pausing the streams results in "TypeError: request.pause is not a function"[/-][+]While streaming data, pausing the stream results in "TypeError: request.pause is not a function"[/+]on Feb 10, 2019
After installing v5.0.0-beta.1 version. It is not connecting to database. Following error is coming:
error: Error connecting database! {"timestamp":"2019-02-28T11:31:14-08:00"}
TypeError: The "config.options.textsize" property must be of type number or null.
at new Connection (/Users//node_modules/tedious/lib/connection.js:589:17)
at base.Promise (/Users//node_modules/mssql/lib/tedious.js:237:23)
at new Promise ()
at ConnectionPool._poolCreate (/Users//node_modules/mssql/lib/tedious.js:195:12)
at ConnectionPool._connect (/Users//node_modules/mssql/lib/base.js:244:10)
at ConnectionPool.connect (/Users//node_modules/mssql/lib/base.js:214:12)
Activity
[-]While streaming data, pausing the streams results in "TypeError: request.pause is not a function"[/-][+]While streaming data, pausing the stream results in "TypeError: request.pause is not a function"[/+]dhensby commentedon Feb 11, 2019
You need to use v5
charutiwari04 commentedon Feb 28, 2019
Hi, I am facing the similar issue.
Software versions:
"mssql": "^4.1.0",(Latest is 4.3.2)
"connect-mssql": "^1.5.0",
nodeJS : v8.12.0
Can someone help? We need to use v5 of what?
dhensby commentedon Feb 28, 2019
Of this library
charutiwari04 commentedon Feb 28, 2019
After installing v5.0.0-beta.1 version. It is not connecting to database. Following error is coming:
charutiwari04 commentedon Feb 28, 2019
Looks like somewhere in your code config.options.textsize is set as string or something else, which should be either integer or null.
dhensby commentedon Mar 1, 2019
@charutiwari04 what version of SQL server are you using and what is
connect-mssql?dhensby commentedon Mar 1, 2019
as a temp fix I assume you can pass through your own
textsizeproperty in your connection configAlso, that is from the tedious lib so you'll have to raise it there
https://github.com/tediousjs/tedious/blob/v6.0.0/src/connection.js#L42 - this is where it's set
charutiwari04 commentedon Mar 1, 2019
Thank you @dhensby As suggested, temporarily it has been fixed. Opened tedious issue for this.