Repository navigation
Description
Hi all,
I'm using the NPM package MSSQL which uses Tedious at its base to communicate to Microsoft SQL Server. When submitting a basic request such as "SELECT * FROM MYTABLE", to a table with a large number of columns (484 columns), the tedious package is erroring out with the following message:
D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\token\stream-parser.js:111
this.suspend(() => {
^
RangeError: Maximum call stack size exceeded
at Parser.awaitData (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\token\stream-parser.js:111:12)
at Parser.readUInt8 (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\token\stream-parser.js:126:10)
at Parser.readBVarChar (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\token\stream-parser.js:320:10)
at readColumnName (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\token\colmetadata-token-parser.js:37:10)
at tableName (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\token\colmetadata-token-parser.js:53:7)
at readTableName (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\token\colmetadata-token-parser.js:32:5)
at metadata (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\token\colmetadata-token-parser.js:52:5)
at udtInfo (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\metadata-parser.js:154:21)
at readUDTInfo (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\metadata-parser.js:130:12)
at schema (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\metadata-parser.js:153:19)
at readSchema (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\metadata-parser.js:106:5)
at collation (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\metadata-parser.js:152:17)
at readCollation (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\metadata-parser.js:81:5)
at scale (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\metadata-parser.js:151:15)
at readScale (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\metadata-parser.js:59:5)
at precision (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\metadata-parser.js:146:13)
at readPrecision (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\metadata-parser.js:51:5)
at dataLength (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\metadata-parser.js:145:11)
at awaitData (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\token\stream-parser.js:129:7)
at Parser.awaitData (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\token\stream-parser.js:109:7)
at Parser.readUInt8 (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\token\stream-parser.js:126:10)
at readDataLength (D:\Dropbox\Projects\node\sequelize-test\node_modules\tedious\lib\metadata-parser.js:31:23)
Upon further testing, I retried the same query using the Sequelize NPM package which using Tedious as its driver and it resulted in the same error message.
So, it appears that the fault lies in the tedious package. Is there an upper limit to the number of columns that can be retrieved using Tedious? Or is this a bug that I've stumbled upon?
When using MSSQL package my code is as follows:
const sql = require('mssql');
async function sql_test() {
config = {
user : 'databaseUser',
password : 'databasePassword',
server : 'serverAddress',
database : 'databaseName'
}
const pool = await sql.connect(config)
const request = new sql.Request(pool)
let output = await request.query('SELECT * FROM MYTABLE')
sql.close()
return output
}
sql_test().then(result => {
console.log(result);
}).catch(e => {
console.log(e);
})
When using Sequelize, my code is the following:
const Sequelize = require('sequelize');
const sequelize = new Sequelize('DatabaseName', 'DatabaseUser', 'DatabasePassword', {
host: 'serverAddress',
dialect: 'mssql'
})
sequelize.query("SELECT * FROM MYTABLE").then(myTableRows => {
console.log(myTableRows)
})
Tedious version is 3.0.1
MSSQL version is 4.3.0
Sequelize version is 4.42.0
Activity
Hadis-Fard commentedon Dec 21, 2018
@caskeychr I've used the first script, everything works fine on my side with 30k rows and 400 columns of type
Varchar(500)using the first script you have posted, could you send the table schema? the result could change depending on data types.caskeychr commentedon Dec 21, 2018
I apologize for the length of the schema ahead of time, but it's mainly just integers and character fields. The only difference is a few decimal fields towards the end.
If you need the actual script from SQL Server for generation, just let me know and I can scrub a copy to post to the forums.
But I have 4 tables in my database with similar schemas that are resulting in the same error. All other tables with smaller column counts(usually less than 100), seem to be working just fine.
I've also run some small tests to see if I could narrow down the issue since I originally believed the problem to be special character related problem (either a / or : ). But when narrowing my results to fields containing these special characters, the query executes without issue.
Also for some extra clarification, these tables only contain anywhere from 10 to 250 records. So they are very much on the small side.
Hadis-Fard commentedon Jan 2, 2019
@caskeychr your both repo script with the table that you've sent works fine and I get the result as
chdh commentedon Jan 29, 2019
Could be related to #843. Did you test with Tedious version >= 4.1.3?
IanChokS commentedon Dec 13, 2019
@caskeychr does upgrading to a later version of tedious fix your problem?
arthurschreiber commentedon Mar 17, 2021
@caskeychr I know it has been quite a while ago when you ran into this issue, but @IanChokS and I opened #1240, which I think should fix tthis. Would you mind checking that out and see if that fixes your problem? 🙇♂️
github-actions commentedon Mar 25, 2021
🎉 This issue has been resolved in version 11.0.7 🎉
The release is available on:
Your semantic-release bot 📦🚀
arthurschreiber commentedon Mar 25, 2021
We just released
[email protected]to thetedious@nextrelease channel. We'd be happy to hear back from you if this fixes the issue you're describing here.If no issues come up, this will be promoted to the
tedious@latestrelease channel automatically in a week.