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 https://github.com/facebook/react-native/pull/12445

Reviewed By: javache

Differential Revision: D4700153

Pulled By: gaearon

fbshipit-source-id: 0c33099babed93b3c70d36ae9dfc7d82460c8269
This commit is contained in:
Dan Abramov 2017-03-20 10:37:58 -07:00 коммит произвёл Facebook Github Bot
Родитель 14fee735a2
Коммит c451dd6cce
1 изменённых файлов: 7 добавлений и 30 удалений

Просмотреть файл

@ -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);
};