Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix it #1370

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

fix it #1370

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions src/pages/api/errorLogger.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { log } from "dbc-node-logger";
import { incErrorCount } from "@/utils/errorCount";

const DELAY = 5000;
let lastMessage = 0;
let errorCounter = 0;

/**
* POST unhandled client side errors to this endpoint
Expand All @@ -28,7 +28,7 @@ export default async function handler(req, res) {
} catch (e) {
parsed = {};
}
errorCounter++;
incErrorCount();

log.error("CLIENT SIDE ERROR", {
clientError: {
Expand All @@ -43,13 +43,3 @@ export default async function handler(req, res) {
res.status(200).json({ message: "OK" });
}
}

/**
* The howru endpoint can get a count here,
* which will let us create alerts, when count is above some threshold
*/
export function getClientSideErrorCount() {
let res = errorCounter;
errorCounter = 0;
return res;
}
14 changes: 1 addition & 13 deletions src/pages/api/howru.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getServerSession } from "@dbcdk/login-nextjs/server";
import { getErrorCount, resetErrorCount } from "@/utils/errorCount";
import getConfig from "next/config";
import { log } from "dbc-node-logger";
import { getClientSideErrorCount } from "./errorLogger";
const { serverRuntimeConfig } = getConfig();
const { maxError500Count } = serverRuntimeConfig;

Expand Down Expand Up @@ -92,17 +91,6 @@ export default async function handler(req, res) {
// push error500 object to results
results.push(error500);

const clientErrors = getClientSideErrorCount();
const clientErrorsOk = clientErrors < maxError500Count;
if (!clientErrorsOk) {
ok = false;
}
results.push({
service: "client-errors",
count: clientErrors,
ok: clientErrorsOk,
});

// Log the service names that cause howru to fail
results
.filter((service) => !service.ok)
Expand All @@ -112,7 +100,7 @@ export default async function handler(req, res) {
});
});

const body = { ok, upSince, services: results, clientErrors };
const body = { ok, upSince, services: results };

log.info("howru status", {
howruStatus: { ok, upSince, body: JSON.stringify(body) },
Expand Down