While streaming data, pausing the stream results in "TypeError: request.pause is not a function"
See original GitHub issueI 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)
Software versions
- NodeJS: v10.15.0
- node-mssql: mssql": “^4.3.1”
- SQL Server: (azure)
Does anyone have a clue?
Issue Analytics
- State:
- Created 5 years ago
- Comments:8
Top Results From Across the Web
node.js - Stream.pause is not a function when uploading file to ...
I get the error stream.pause is not a function which is called by the azure-storage at the start of the upload because the...
Read more >What is Stream Module pause() in Node.js? - Educative.io
This method pauses the reading of data from a file. Any data that exists during this pause operation can be found in the...
Read more >Stream | Node.js v19.3.0 Documentation
Writing data while the stream is not draining is particularly problematic for a Transform , because the Transform streams are paused by default...
Read more >Is Request.pause useless? - Google Groups
I have to pause the request so I can handle the on 'data'. ... the TCP connection, all while the server is "paused"...
Read more >Node.js Stream readable.pause() Method - GeeksforGeeks
Parameters: This method does not accept any parameters. Return Value: If this method is used then the reading of data is paused at...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank you @dhensby As suggested, temporarily it has been fixed. Opened tedious issue for this.
as a temp fix I assume you can pass through your own
textsize
property 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