Skip to content

Commit

Permalink
Accept any 2xx nested hearbeat status code
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhamlett committed Oct 8, 2024
1 parent 0a4082e commit 7bbc95b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/core/WakaTimeCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,19 @@ class WakaTimeCore {
if (response.status === 202 || response.status === 201) {
await Promise.all(
(data.responses ?? []).map(async (resp, respNumber) => {
if (resp[0].error) {
const nestedResp = resp[0];
const nestedStatus = resp[1];
if (nestedResp.error) {
await this.putHeartbeatsBackInQueue(heartbeats.filter((h, i) => i === respNumber));
console.error(resp[0].error);
} else if (resp[1] === 201 || resp[1] === 202) {
} else if (nestedStatus >= 200 && nestedStatus <= 299) {
await changeExtensionStatus('allGood');
} else {
if (resp[1] !== 400) {
if (nestedStatus !== 400) {
await this.putHeartbeatsBackInQueue(heartbeats.filter((h, i) => i === respNumber));
}
console.error(
`Heartbeat ${resp[0].data?.id ?? respNumber} returned status: ${resp[1]}`,
`Heartbeat ${nestedResp.data?.id ?? respNumber} returned status: ${nestedStatus}`,
);
}
return resp;
Expand Down

0 comments on commit 7bbc95b

Please sign in to comment.