Track socket usage during file download
Summary: Should help to investigate further issues like https://fb.workplace.com/groups/flippersupport/permalink/1577911229356196/ Reviewed By: passy Differential Revision: D43692927 fbshipit-source-id: 723b051f748946c89ece85fb6c11c40705196fe4
This commit is contained in:
committed by
Facebook GitHub Bot
parent
fa74ebba68
commit
39b14fc428
@@ -11,6 +11,8 @@ import {FlipperServerCommands, FlipperServerEvents, uuid} from 'flipper-common';
|
||||
import {pathExists} from 'fs-extra';
|
||||
import {promises, createWriteStream, ReadStream} from 'fs';
|
||||
import axios from 'axios';
|
||||
import http from 'http';
|
||||
import https from 'https';
|
||||
|
||||
const {unlink} = promises;
|
||||
|
||||
@@ -43,6 +45,21 @@ export const commandDownloadFileStartFactory =
|
||||
await unlink(dest);
|
||||
}
|
||||
|
||||
console.debug('commandDownloadFileStartFactory -> start', {
|
||||
http: {
|
||||
usedSockets: Object.keys(http.globalAgent.sockets).length,
|
||||
freeSocket: Object.keys(http.globalAgent.freeSockets).length,
|
||||
maxSockets: http.globalAgent.maxSockets,
|
||||
maxTotalSockets: http.globalAgent.maxTotalSockets,
|
||||
},
|
||||
https: {
|
||||
usedSockets: Object.keys(https.globalAgent.sockets).length,
|
||||
freeSocket: Object.keys(https.globalAgent.freeSockets).length,
|
||||
maxSockets: https.globalAgent.maxSockets,
|
||||
maxTotalSockets: https.globalAgent.maxTotalSockets,
|
||||
},
|
||||
});
|
||||
|
||||
const downloadId = uuid();
|
||||
|
||||
const response = await axios.request<ReadStream>({
|
||||
@@ -84,6 +101,16 @@ export const commandDownloadFileStartFactory =
|
||||
totalSize,
|
||||
status: 'success',
|
||||
});
|
||||
console.debug('commandDownloadFileStartFactory -> finish', {
|
||||
http: {
|
||||
usedSockets: Object.keys(http.globalAgent.sockets).length,
|
||||
freeSocket: Object.keys(http.globalAgent.freeSockets).length,
|
||||
},
|
||||
https: {
|
||||
usedSockets: Object.keys(https.globalAgent.sockets).length,
|
||||
freeSocket: Object.keys(https.globalAgent.freeSockets).length,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
writeStream.on('error', (e: Error) => {
|
||||
@@ -96,6 +123,16 @@ export const commandDownloadFileStartFactory =
|
||||
message: e.message,
|
||||
stack: e.stack,
|
||||
});
|
||||
console.debug('commandDownloadFileStartFactory -> error', {
|
||||
http: {
|
||||
usedSockets: Object.keys(http.globalAgent.sockets).length,
|
||||
freeSocket: Object.keys(http.globalAgent.freeSockets).length,
|
||||
},
|
||||
https: {
|
||||
usedSockets: Object.keys(https.globalAgent.sockets).length,
|
||||
freeSocket: Object.keys(https.globalAgent.freeSockets).length,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user