Skip to content

Commit 795cd62

Browse files
author
Sylvestre
authored
No error on stream (#45)
* no error on stream * logging stream error
1 parent f919f10 commit 795cd62

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/mssql.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,18 @@ export async function queryStream(req, res, pool) {
101101
new Transform({
102102
objectMode: true,
103103
transform(chunk, encoding, cb) {
104-
if (Array.isArray(chunk)) {
105-
const row = chunk.reduce((acc, r, idx) => {
104+
let row = null;
105+
try {
106+
row = chunk.reduce((acc, r, idx) => {
106107
const key = columnNameMap.get(idx);
107108
return {...acc, [key]: r};
108109
}, {});
109-
cb(null, row);
110-
} else {
111-
cb(new Error("row has unexpected format"), chunk);
110+
} catch (e) {
111+
console.error("row has unexpected format");
112+
// TODO: Add error handling once server supports handling error for in flight streamed response
113+
// cb(new Error(e));
112114
}
115+
cb(null, row);
113116
},
114117
})
115118
)

0 commit comments

Comments
 (0)