Skip to content

Commit

Permalink
Fixed an issue where node client was sending some unicode data which …
Browse files Browse the repository at this point in the history
…broke event submission.

We need to take a closer look into this in the future...

nwjs/nw.js#1570

http://stackoverflow.com/questions/10430562/how-do-you-remove-unicode-characters-in-javascript
  • Loading branch information
niemyjski committed Jun 2, 2015
1 parent 8b667c0 commit 30042f5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 29 deletions.
20 changes: 8 additions & 12 deletions dist/exceptionless.node.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/exceptionless.node.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/services/NodeEnvironmentInfoCollector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ export class NodeEnvironmentInfoCollector implements IEnvironmentInfoCollector {
if (!os) {
return null;
}

var environmentInfo: IEnvironmentInfo = {
processor_count: os.cpus().length,
total_physical_memory: os.totalmem(),
available_physical_memory: os.freemem(),
command_line: process.argv.join(' '),
process_name: process.title,
process_name: (process.title || '').replace(/[\uE000-\uF8FF]/g, ''),
process_id: process.pid + '',
process_memory_size: process.memoryUsage().heapTotal,
//thread_id: '',
Expand Down
23 changes: 9 additions & 14 deletions src/submission/NodeSubmissionClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ export class NodeSubmissionClient extends DefaultSubmissionClient {
}

public sendRequest(config:Configuration, method:string, path:string, data:string, callback: (status:number, message:string, data?:string, headers?:Object) => void): void {
function complete(response:http.IncomingMessage, data:string, headers:Object) {
function complete(response:http.IncomingMessage, responseBody:string, responseHeaders:Object) {
var message:string;
if (response.statusCode === 0) {
message = 'Unable to connect to server.';
} else if (response.statusCode < 200 || response.statusCode > 299) {
message = response.statusMessage || (<any>response).message;
}

callback(response.statusCode || 500, message, data, headers);
callback(response.statusCode || 500, message, responseBody, responseHeaders);
}

var parsedHost = url.parse(config.serverUrl);
Expand All @@ -35,7 +35,7 @@ export class NodeSubmissionClient extends DefaultSubmissionClient {
hostname: parsedHost.hostname,
method: method,
port: parsedHost.port && parseInt(parsedHost.port),
path: path,
path: path
};

if (method === 'POST') {
Expand All @@ -44,21 +44,16 @@ export class NodeSubmissionClient extends DefaultSubmissionClient {
'Content-Length': data.length
}
}

options.headers['User-Agent'] = config.userAgent;
var request:http.ClientRequest = (parsedHost.protocol === 'https' ? https : http).request(options, (response:http.IncomingMessage) => {
var body = '';
response.on('data', chunk => body += chunk);
response.on('end', () => {
complete(response, body, response.headers);
});
});

request.on('error', function(e) {
callback(500, e.message);
response.setEncoding('utf8');
response.on('data', (chunk) => body += chunk);
response.on('end', () => complete(response, body, response.headers));
});

!!data && request.write(data);
request.end();
request.on('error', (error:Error) => callback(500, error.message));
request.end(data);
}
}

0 comments on commit 30042f5

Please sign in to comment.