Skip to content

RangeError: Maximum call stack size exceeded #839

Closed

Description

@caskeychr

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

  1. Hadis-Fard commented on Dec 21, 2018

    @Hadis-Fard

    @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.

  2. caskeychr commented on Dec 21, 2018

    @caskeychr
    Author

    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.

    Column Name Data Type Nullable?
    Record_Number [int] IDENTITY(1,1) NOT NULL,
    Column_1 char NULL,
    Column_2 [int] NULL,
    Column_3 char NULL,
    Column_4 char NULL,
    Column_5 char NULL,
    Column_6 char NULL,
    Column_7 [int] NULL,
    Column_8 [int] NULL,
    Column_9 [int] NULL,
    Column_10 [int] NULL,
    Column_11 [int] NULL,
    Column_12 char NULL,
    Column_13 char NULL,
    Column_14 char NULL,
    Column_15 char NULL,
    Column_16 char NULL,
    Column_17 char NULL,
    Column_18 char NULL,
    Column_19 char NULL,
    Column_20 char NULL,
    Column_21 char NULL,
    Column_22 char NULL,
    Column_23 char NULL,
    Column_24 char NULL,
    Column_25 char NULL,
    Column_26 char NULL,
    Column_27 char NULL,
    Column_28 char NULL,
    Column_29 char NULL,
    Column_30 char NULL,
    Column_31 char NULL,
    Column_32 char NULL,
    Column_33 char NULL,
    Column_34 char NULL,
    Column_35 char NULL,
    Column_36 char NULL,
    Column_37 char NULL,
    Column_38 char NULL,
    Column_39 [int] NULL,
    Column_40 [int] NULL,
    Column_41 [int] NULL,
    Column_42 [int] NULL,
    Column_43 [int] NULL,
    Column_44 [int] NULL,
    Column_45 [int] NULL,
    Column_46 [int] NULL,
    Column_47 [int] NULL,
    Column_48 [int] NULL,
    Column_49 [int] NULL,
    Column_50 [int] NULL,
    Column_51 char NULL,
    Column_52 [int] NULL,
    Column_53 char NULL,
    Column_54 [int] NULL,
    Column_55 [int] NULL,
    Column_56 [int] NULL,
    Column_57 [int] NULL,
    Column_58 [int] NULL,
    Column_59 [int] NULL,
    Column_60 [int] NULL,
    Column_61 [int] NULL,
    Column_62 [int] NULL,
    Column_63 [int] NULL,
    Column_64 [int] NULL,
    Column_65 char NULL,
    Column_66 [int] NULL,
    Column_67 char NULL,
    Column_68 [int] NULL,
    Column_69 char NULL,
    Column_70 char NULL,
    Column_71 char NULL,
    Column_72 [int] NULL,
    Column_73 [int] NULL,
    Column_74 [int] NULL,
    Column_75 [int] NULL,
    Column_76 [int] NULL,
    Column_77 [int] NULL,
    Column_78 [int] NULL,
    Column_79 [int] NULL,
    Column_80 [int] NULL,
    Column_81 [int] NULL,
    Column_82 [int] NULL,
    Column_83 [int] NULL,
    Column_84 [int] NULL,
    Column_85 [int] NULL,
    Column_86 [int] NULL,
    Column_87 [int] NULL,
    Column_88 [int] NULL,
    Column_89 [int] NULL,
    Column_90 [int] NULL,
    Column_91 [int] NULL,
    Column_92 [int] NULL,
    Column_93 [int] NULL,
    Column_94 [int] NULL,
    Column_95 [int] NULL,
    Column_96 [int] NULL,
    Column_97 [int] NULL,
    Column_98 [int] NULL,
    Column_99 char NULL,
    Column_100 [int] NULL,
    Column_101 [int] NULL,
    Column_102 [int] NULL,
    Column_103 char NULL,
    Column_104 char NULL,
    Column_105 char NULL,
    Column_106 char NULL,
    Column_107 char NULL,
    Column_108 char NULL,
    Column_109 char NULL,
    Column_110 char NULL,
    Column_111 char NULL,
    Column_112 [int] NULL,
    Column_113 [int] NULL,
    Column_114 [int] NULL,
    Column_115 [int] NULL,
    Column_116 [int] NULL,
    Column_117 [int] NULL,
    Column_118 [int] NULL,
    Column_119 char NULL,
    Column_120 char NULL,
    Column_121 char NULL,
    Column_122 char NULL,
    Column_123 char NULL,
    Column_124 [int] NULL,
    Column_125 [int] NULL,
    Column_126 [int] NULL,
    Column_127 [int] NULL,
    Column_128 [int] NULL,
    Column_129 char NULL,
    Column_130 [int] NULL,
    Column_131 [int] NULL,
    Column_132 [int] NULL,
    Column_133 char NULL,
    Column_134 char NULL,
    Column_135 char NULL,
    Column_136 char NULL,
    Column_137 char NULL,
    Column_138 char NULL,
    Column_139 char NULL,
    Column_140 char NULL,
    Column_141 char NULL,
    Column_142 [int] NULL,
    Column_143 [int] NULL,
    Column_144 [int] NULL,
    Column_145 [int] NULL,
    Column_146 [int] NULL,
    Column_147 [int] NULL,
    Column_148 [int] NULL,
    Column_149 char NULL,
    Column_150 char NULL,
    Column_151 char NULL,
    Column_152 char NULL,
    Column_153 char NULL,
    Column_154 [int] NULL,
    Column_155 [int] NULL,
    Column_156 [int] NULL,
    Column_157 [int] NULL,
    Column_158 char NULL,
    Column_159 [int] NULL,
    Column_160 [int] NULL,
    Column_161 [int] NULL,
    Column_162 char NULL,
    Column_163 char NULL,
    Column_164 char NULL,
    Column_165 char NULL,
    Column_166 char NULL,
    Column_167 char NULL,
    Column_168 char NULL,
    Column_169 char NULL,
    Column_170 char NULL,
    Column_171 [int] NULL,
    Column_172 [int] NULL,
    Column_173 [int] NULL,
    Column_174 [int] NULL,
    Column_175 [int] NULL,
    Column_176 [int] NULL,
    Column_177 [int] NULL,
    Column_178 [int] NULL,
    Column_179 [int] NULL,
    Column_180 char NULL,
    Column_181 char NULL,
    Column_182 char NULL,
    Column_183 char NULL,
    Column_184 char NULL,
    Column_185 [int] NULL,
    Column_186 [int] NULL,
    Column_187 [int] NULL,
    Column_188 [int] NULL,
    Column_189 [int] NULL,
    Column_190 [int] NULL,
    Column_191 [int] NULL,
    Column_192 [int] NULL,
    Column_193 [int] NULL,
    Column_194 [int] NULL,
    Column_195 [int] NULL,
    Column_196 [int] NULL,
    Column_197 [int] NULL,
    Column_198 [int] NULL,
    Column_199 [int] NULL,
    Column_200 [int] NULL,
    Column_201 [int] NULL,
    Column_202 [int] NULL,
    Column_203 [int] NULL,
    Column_204 char NULL,
    Column_205 [int] NULL,
    Column_206 [int] NULL,
    Column_207 [int] NULL,
    Column_208 char NULL,
    Column_209 char NULL,
    Column_210 char NULL,
    Column_211 char NULL,
    Column_212 char NULL,
    Column_213 char NULL,
    Column_214 char NULL,
    Column_215 char NULL,
    Column_216 char NULL,
    Column_217 [int] NULL,
    Column_218 [int] NULL,
    Column_219 [int] NULL,
    Column_220 [int] NULL,
    Column_221 [int] NULL,
    Column_222 [int] NULL,
    Column_223 [int] NULL,
    Column_224 char NULL,
    Column_225 char NULL,
    Column_226 char NULL,
    Column_227 char NULL,
    Column_228 char NULL,
    Column_229 [int] NULL,
    Column_230 char NULL,
    Column_231 [int] NULL,
    Column_232 [int] NULL,
    Column_233 [int] NULL,
    Column_234 char NULL,
    Column_235 char NULL,
    Column_236 char NULL,
    Column_237 char NULL,
    Column_238 char NULL,
    Column_239 char NULL,
    Column_240 char NULL,
    Column_241 char NULL,
    Column_242 char NULL,
    Column_243 [int] NULL,
    Column_244 [int] NULL,
    Column_245 [int] NULL,
    Column_246 [int] NULL,
    Column_247 [int] NULL,
    Column_248 [int] NULL,
    Column_249 [int] NULL,
    Column_250 char NULL,
    Column_251 char NULL,
    Column_252 char NULL,
    Column_253 char NULL,
    Column_254 char NULL,
    Column_255 [int] NULL,
    Column_256 [int] NULL,
    Column_257 [int] NULL,
    Column_258 [int] NULL,
    Column_259 [int] NULL,
    Column_260 [int] NULL,
    Column_261 [int] NULL,
    Column_262 [int] NULL,
    Column_263 [int] NULL,
    Column_264 [int] NULL,
    Column_265 [int] NULL,
    Column_266 [int] NULL,
    Column_267 [int] NULL,
    Column_268 [int] NULL,
    Column_269 [int] NULL,
    Column_270 char NULL,
    Column_271 [int] NULL,
    Column_272 [int] NULL,
    Column_273 [int] NULL,
    Column_274 char NULL,
    Column_275 char NULL,
    Column_276 char NULL,
    Column_277 char NULL,
    Column_278 char NULL,
    Column_279 char NULL,
    Column_280 char NULL,
    Column_281 char NULL,
    Column_282 char NULL,
    Column_283 [int] NULL,
    Column_284 [int] NULL,
    Column_285 [int] NULL,
    Column_286 [int] NULL,
    Column_287 [int] NULL,
    Column_288 [int] NULL,
    Column_289 [int] NULL,
    Column_290 char NULL,
    Column_291 char NULL,
    Column_292 char NULL,
    Column_293 char NULL,
    Column_294 char NULL,
    Column_295 [int] NULL,
    Column_296 char NULL,
    Column_297 [int] NULL,
    Column_298 [int] NULL,
    Column_299 [int] NULL,
    Column_300 char NULL,
    Column_301 char NULL,
    Column_302 char NULL,
    Column_303 char NULL,
    Column_304 char NULL,
    Column_305 char NULL,
    Column_306 char NULL,
    Column_307 char NULL,
    Column_308 char NULL,
    Column_309 [int] NULL,
    Column_310 [int] NULL,
    Column_311 [int] NULL,
    Column_312 [int] NULL,
    Column_313 [int] NULL,
    Column_314 [int] NULL,
    Column_315 [int] NULL,
    Column_316 char NULL,
    Column_317 char NULL,
    Column_318 char NULL,
    Column_319 char NULL,
    Column_320 char NULL,
    Column_321 [int] NULL,
    Column_322 [int] NULL,
    Column_323 [int] NULL,
    Column_324 [int] NULL,
    Column_325 [int] NULL,
    Column_326 [int] NULL,
    Column_327 [int] NULL,
    Column_328 [int] NULL,
    Column_329 char NULL,
    Column_330 [int] NULL,
    Column_331 [int] NULL,
    Column_332 [int] NULL,
    Column_333 char NULL,
    Column_334 char NULL,
    Column_335 char NULL,
    Column_336 char NULL,
    Column_337 char NULL,
    Column_338 char NULL,
    Column_339 char NULL,
    Column_340 char NULL,
    Column_341 char NULL,
    Column_342 [int] NULL,
    Column_343 [int] NULL,
    Column_344 [int] NULL,
    Column_345 [int] NULL,
    Column_346 [int] NULL,
    Column_347 [int] NULL,
    Column_348 [int] NULL,
    Column_349 char NULL,
    Column_350 char NULL,
    Column_351 char NULL,
    Column_352 char NULL,
    Column_353 char NULL,
    Column_354 [int] NULL,
    Column_355 char NULL,
    Column_356 [int] NULL,
    Column_357 [int] NULL,
    Column_358 [int] NULL,
    Column_359 char NULL,
    Column_360 char NULL,
    Column_361 char NULL,
    Column_362 char NULL,
    Column_363 char NULL,
    Column_364 char NULL,
    Column_365 char NULL,
    Column_366 char NULL,
    Column_367 char NULL,
    Column_368 [int] NULL,
    Column_369 [int] NULL,
    Column_370 [int] NULL,
    Column_371 [int] NULL,
    Column_372 [int] NULL,
    Column_373 [int] NULL,
    Column_374 [int] NULL,
    Column_375 char NULL,
    Column_376 char NULL,
    Column_377 char NULL,
    Column_378 char NULL,
    Column_379 char NULL,
    Column_380 [int] NULL,
    Column_381 [int] NULL,
    Column_382 [int] NULL,
    Column_383 [int] NULL,
    Column_384 [int] NULL,
    Column_385 [int] NULL,
    Column_386 [int] NULL,
    Column_387 [int] NULL,
    Column_388 [int] NULL,
    Column_389 [int] NULL,
    Column_390 [int] NULL,
    Column_391 [int] NULL,
    Column_392 [int] NULL,
    Column_393 [int] NULL,
    Column_394 [int] NULL,
    Column_395 [int] NULL,
    Column_396 [int] NULL,
    Column_397 [int] NULL,
    Column_398 [int] NULL,
    Column_399 [int] NULL,
    Column_400 [int] NULL,
    Column_401 [int] NULL,
    Column_402 [int] NULL,
    Column_403 [int] NULL,
    Column_404 [int] NULL,
    Column_405 [int] NULL,
    Column_406 [int] NULL,
    Column_407 [int] NULL,
    Column_408 [int] NULL,
    Column_409 [int] NULL,
    Column_410 [int] NULL,
    Column_411 [int] NULL,
    Column_412 [int] NULL,
    Column_413 [int] NULL,
    Column_414 [int] NULL,
    Column_415 [int] NULL,
    Column_416 [int] NULL,
    Column_417 [int] NULL,
    Column_418 [int] NULL,
    Column_419 [int] NULL,
    Column_420 [int] NULL,
    Column_421 [int] NULL,
    Column_422 [int] NULL,
    Column_423 [int] NULL,
    Column_424 [int] NULL,
    Column_425 [int] NULL,
    Column_426 [int] NULL,
    Column_427 [int] NULL,
    Column_428 [int] NULL,
    Column_429 [int] NULL,
    Column_430 [int] NULL,
    Column_431 [int] NULL,
    Column_432 [int] NULL,
    Column_433 [int] NULL,
    Column_434 [int] NULL,
    Column_435 [int] NULL,
    Column_436 [int] NULL,
    Column_437 [int] NULL,
    Column_438 [int] NULL,
    Column_439 [int] NULL,
    Column_440 [int] NULL,
    Column_441 [int] NULL,
    Column_442 [int] NULL,
    Column_443 [int] NULL,
    Column_444 [int] NULL,
    Column_445 [int] NULL,
    Column_446 [int] NULL,
    Column_447 [int] NULL,
    Column_448 [int] NULL,
    Column_449 [int] NULL,
    Column_450 [int] NULL,
    Column_451 [int] NULL,
    Column_452 [int] NULL,
    Column_453 [int] NULL,
    Column_454 [int] NULL,
    Column_455 [int] NULL,
    Column_456 [int] NULL,
    Column_457 [int] NULL,
    Column_458 [int] NULL,
    Column_459 [int] NULL,
    Column_460 [int] NULL,
    Column_461 [int] NULL,
    Column_462 [int] NULL,
    Column_463 [int] NULL,
    Column_464 [int] NULL,
    Column_465 [int] NULL,
    Column_466 [int] NULL,
    Column_467 [int] NULL,
    Column_468 [int] NULL,
    Column_469 [int] NULL,
    Column_470 [int] NULL,
    Column_471 [int] NULL,
    Column_472 [int] NULL,
    Column_473 char NULL,
    Column_474 [int] NULL,
    Column_475 [int] NULL,
    Column_476 [int] NULL,
    Column_477 [int] NULL,
    Column_478 [int] NULL,
    Column_479 decimal NULL,
    Column_480 decimal NULL,
    Column_481 [int] NULL,
    Column_482 [int] NULL,
    Column_483 [int] NULL,
    Column_484 [int] NULL,
    Column_485 char NULL,
  3. Hadis-Fard commented on Jan 2, 2019

    @Hadis-Fard

    @caskeychr your both repo script with the table that you've sent works fine and I get the result as

    .....
           Column_481: 1,
           Column_482: 1,
           Column_483: 1,
           Column_484: 1,
           Column_485: 'a' },
         ... 19899 more items ],
      output: {},
      rowsAffected: [ 19999 ] }
    
  4. chdh commented on Jan 29, 2019

    @chdh
    Collaborator

    Could be related to #843. Did you test with Tedious version >= 4.1.3?

  5. IanChokS commented on Dec 13, 2019

    @IanChokS
    Member

    @caskeychr does upgrading to a later version of tedious fix your problem?

  6. added
    Idle
    on Dec 13, 2019
  7. arthurschreiber commented on Mar 17, 2021

    @arthurschreiber
    Collaborator

    @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? 🙇‍♂️

  8. github-actions commented on Mar 25, 2021

    @github-actions
    Contributor

    🎉 This issue has been resolved in version 11.0.7 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

  9. arthurschreiber commented on Mar 25, 2021

    @arthurschreiber
    Collaborator

    We just released [email protected] to the tedious@next release 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@latest release channel automatically in a week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Idlereleased

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions