I've created a Server.IO app that the client connected will request data from. The data is read from a zip file and correctly sends the data to the client.
io.sockets.on('connection', function (socket) {
fs.readFile("myzip.zip", function(err, data) {
if (err) throw err;
socket.zip = new JSZip(data);
});
// when the client emits 'getdata', this listens and executes
socket.on('getdata', function(filename){
console.log(filename);
var data = socket.zip.file(filename + '.txt').asText()
console.log(data);
// return the data to the client-side
io.sockets.emit('updatedata', filename, data);
});
});
On the client side, I'm requesting the data
var socket = io.connect(URL);
// on connection to server
socket.on('connect', function(){
socket.emit('getdata','data_file1');
socket.emit('getdata','data_file2');
socket.emit('getdata','data_file3');
});
socket.on('updatedata', function (filename, data) {
console.log('updatedata ' + filename);
$('#' + filename).append(data + '<br>');
});
However there are a couple of text files that when are attempted to be read in a normal non-debug mode that will seemingly cause the NodeJS app to exit with no error message or stacktrace.
This happens when I run as node server.js
The last line to execute is var data = socket.zip.file(filename + '.txt').asText();
but I haven't figured out how to debug this because if I run this app in debug mode, the whole thing works.
I run with debug mode as node debug server.js
The text files are simple CSV files and some of them are small and some are large, but the file size doesn't appear to be related. The files are also all UTF8 without BOM.
Any idea on how to fix this or figure out why it works in debug mode and not otherwise?