Description
PreparedStatement.execute(values) throws a TypeError at runtime when stream = true and no callback is provided.
Root Cause
In lib/base/prepared-statement.js, execute() has the condition:
if (this.stream || (typeof callback === 'function')) {
return this._execute(values, callback)
}
When stream = true and no callback, this enters _execute(values, undefined). Inside _execute, the inner request completion handler unconditionally calls callback(null, result), which throws TypeError: callback is not a function.
Expected Behaviour
Calling ps.execute(values) with ps.stream = true and no callback should work — results should be consumed via row/error/done events on the underlying request, consistent with how Request.query() and Request.batch() handle streaming without a callback.
Steps to Reproduce
const sql = require('mssql')
const pool = await sql.connect(config)
const ps = new sql.PreparedStatement(pool)
ps.stream = true
ps.input('id', sql.Int)
await ps.prepare('SELECT @id AS id')
// This throws TypeError: callback is not a function
ps.execute({ id: 1 })
Workaround
Provide a no-op callback:
ps.execute({ id: 1 }, () => {})
Description
PreparedStatement.execute(values)throws aTypeErrorat runtime whenstream = trueand no callback is provided.Root Cause
In
lib/base/prepared-statement.js,execute()has the condition:When
stream = trueand no callback, this enters_execute(values, undefined). Inside_execute, the inner request completion handler unconditionally callscallback(null, result), which throwsTypeError: callback is not a function.Expected Behaviour
Calling
ps.execute(values)withps.stream = trueand no callback should work — results should be consumed viarow/error/doneevents on the underlying request, consistent with howRequest.query()andRequest.batch()handle streaming without a callback.Steps to Reproduce
Workaround
Provide a no-op callback: