mirror of
https://github.com/status-im/react-native.git
synced 2025-02-25 23:55:23 +00:00
fix error handling in react native heap capture server middleware
Reviewed By: bnham Differential Revision: D3684092 fbshipit-source-id: 1856fa4c04a173e1df49dfe17ebef09a066447e5
This commit is contained in:
parent
e6b850871b
commit
c43c80bd7c
@ -25,8 +25,12 @@ module.exports = function(req, res, next) {
|
||||
fs.appendFileSync(preload, req.rawBody);
|
||||
fs.appendFileSync(preload, ';');
|
||||
res.end();
|
||||
const captureDir = path.join(__dirname, 'heapCapture/captures');
|
||||
if (!fs.existsSync(captureDir)) {
|
||||
fs.mkdirSync(captureDir);
|
||||
}
|
||||
console.log('Packaging Trace');
|
||||
var captureHtml = path.join(__dirname, 'heapCapture/captures/capture_' + Date.now() + '.html');
|
||||
var captureHtml = captureDir + '/capture_' + Date.now() + '.html';
|
||||
var capture = fs.createWriteStream(captureHtml);
|
||||
var inliner = spawn(
|
||||
'inliner',
|
||||
@ -35,6 +39,10 @@ module.exports = function(req, res, next) {
|
||||
stdio: [ process.stdin, 'pipe', process.stderr ],
|
||||
});
|
||||
inliner.stdout.pipe(capture);
|
||||
inliner.on('error', (err) => {
|
||||
console.error('Error processing heap capture: ' + err.message);
|
||||
console.error('make sure you have installed inliner with \'npm install inliner -g\'');
|
||||
});
|
||||
inliner.on('exit', (code, signal) => {
|
||||
if (code === 0) {
|
||||
console.log('Heap capture written to: ' + captureHtml);
|
||||
|
Loading…
x
Reference in New Issue
Block a user