-
Notifications
You must be signed in to change notification settings - Fork 297
Closed
Description
- Version: nodejs 4.4.4
- Platform:windows 10
Hi to node big community
i'm so confused...i make api server to handle and deliver data from oracle database
related to my big amount of data record(~ 2 million per request) i decide to use streaming for avoid mem leak
i use node oracle db interface that can fetch data and deliver it as stream to server(object mode)....but when i want to write these objects to response with response.write() after seconds, response close event trigger and connection lost!
It might be fun to know i check response to be drained and even set shouldKeepAlive : true in res body
so///why response lost connection and end it too early?
tnx for your help :)
code :
var counter = 0;
var stream = connection.query(input.query, [], {streamResults: true});
stream.on('data', function (row) {
if (checkForDataSend) {
var writeStream = JSON.stringify(row) + ","
checkForDataSend = response.write(writeStream, 'utf-8');
} else {
stream.pause();
}
});
response.on('drain', function () {
checkForDataSend = true;
stream.resume();
});
response.on('close', function () {
console.log("response close event sent",counter)
});
response.on('finish', function () {
console.log("everything is finished", counter)
});
stream.on('end', function () {
console.log("now fetch data is ended");
response.end();
dbi.releaseConnection(connection, function (err) {
if (err) {
done(err);
}
})
});
stream.on('error', function (err) {
dbi.releaseConnection(connection, function (err) {
if (err) {
done(err);
}
})
})`
>
Metadata
Metadata
Assignees
Labels
No labels