Permalink
Browse files

Update message with instructions

Summary:
The middleware for automatically converting Systrace traces to HTML and popping the browser hasn't worked properly for a while, since the version on Homebrew generates some code that uses `Object.observe`, which was deleted from Chrome ages ago. People have complained about it, but fixing it properly has proven to be harder than expected, so I suggest we simply update the message with instructions for people to load it on Chrome, which is what all of us have been doing anyway (AFAIK).
Closes #12445

Reviewed By: javache

Differential Revision: D4700153

Pulled By: gaearon

fbshipit-source-id: 0c33099babed93b3c70d36ae9dfc7d82460c8269
  • Loading branch information...
gaearon authored and facebook-github-bot committed Mar 20, 2017
1 parent 14fee73 commit c451dd6cceb526d4814993e4d0eb431375a9b01c
Showing with 7 additions and 30 deletions.
  1. +7 −30 local-cli/server/middleware/systraceProfileMiddleware.js
@@ -8,9 +8,7 @@
*/
'use strict';
const exec = require('child_process').exec;
const fs = require('fs');
const path = require('path');
module.exports = function(req, res, next) {
if (req.url !== '/systrace') {
@@ -20,33 +18,12 @@ module.exports = function(req, res, next) {
console.log('Dumping profile information...');
var dumpName = '/tmp/dump_' + Date.now() + '.json';
var prefix = process.env.TRACE_VIEWER_PATH || '';
var cmd = path.join(prefix, 'trace2html') + ' ' + dumpName;
fs.writeFileSync(dumpName, req.rawBody);
exec(cmd, function(error) {
if (error) {
if (error.code === 127) {
var response = '\n** Failed executing `' + cmd + '` **\n\n' +
'Google trace-viewer is required to visualize the data, ' +
'You can install it with `brew install trace2html`\n\n' +
'NOTE: Your profile data was kept at:\n' + dumpName;
console.log(response);
res.end(response);
} else {
console.error(error);
res.end('Unknown error: ' + error.message);
}
return;
} else {
exec('rm ' + dumpName);
exec('open ' + dumpName.replace(/json$/, 'html'), function(err) {
if (err) {
console.error(err);
res.end(err.message);
} else {
res.end();
}
});
}
});
var response =
'Your profile was saved at:\n' + dumpName + '\n\n' +
'On Google Chrome navigate to chrome://tracing and then click on "load" ' +
'to load and visualise your profile.\n\n' +
'This message is also printed to your console by the packager so you can copy it :)';
console.log(response);
res.end(response);
};

0 comments on commit c451dd6

Please sign in to comment.