mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
feat: Remove ongoingRequestCount counter
This commit is contained in:
parent
8c6be158d7
commit
010fa2ca83
@ -18,9 +18,7 @@ const isUuid = RegExp.prototype.test.bind(
|
||||
/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/
|
||||
);
|
||||
|
||||
// TODO: CLEAN UP THESE
|
||||
let serverlessRunEndTime;
|
||||
let ongoingRequestsCount = 0;
|
||||
|
||||
const logError = (type, error) => {
|
||||
if (!process.env.SLS_STATS_DEBUG) return;
|
||||
@ -37,12 +35,10 @@ const processResponseBody = async (response, ids, startTime) => {
|
||||
} catch (error) {
|
||||
logError(`Response processing error for ${ids || '<no id>'}`, error);
|
||||
return null;
|
||||
} finally {
|
||||
--ongoingRequestsCount;
|
||||
}
|
||||
|
||||
const endTime = Date.now();
|
||||
if (serverlessRunEndTime && !ongoingRequestsCount && process.env.SLS_STATS_DEBUG) {
|
||||
if (serverlessRunEndTime && process.env.SLS_STATS_DEBUG) {
|
||||
log(
|
||||
format(
|
||||
'Stats request prevented process from exiting for %dms (request time: %dms)',
|
||||
@ -55,7 +51,6 @@ const processResponseBody = async (response, ids, startTime) => {
|
||||
};
|
||||
|
||||
async function request(payload, { ids, timeout } = {}) {
|
||||
++ongoingRequestsCount;
|
||||
const startTime = Date.now();
|
||||
let response;
|
||||
const body = JSON.stringify(payload);
|
||||
@ -100,7 +95,7 @@ async function report(payload, options = {}) {
|
||||
if (!analyticsUrl) return null;
|
||||
const isForced = options && options.isForced;
|
||||
if (areAnalyticsDisabled && !isForced) return null;
|
||||
if (!cacheDirPath) return request(payload);
|
||||
if (!cacheDirPath) return request([payload]);
|
||||
const id = uuid();
|
||||
|
||||
const [, requestResult] = await Promise.all([
|
||||
@ -140,8 +135,6 @@ async function sendPending(options = {}) {
|
||||
|
||||
process.nextTick(markServerlessRunEnd);
|
||||
|
||||
// TODO: TESTS
|
||||
// TODO: CHANGE NAME
|
||||
const payloadsWithIds = (
|
||||
await Promise.all(
|
||||
dirFilenames.map(async (dirFilename) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user