Skip to content

Commit

Permalink
fix: Response debug logging refers to request variables, which is bot…
Browse files Browse the repository at this point in the history
…h wrong AND confusing.
  • Loading branch information
adam-coster committed Oct 7, 2021
1 parent 3fc38d3 commit bed3966
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/lib/clientLib/FavroClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,19 @@ export class FavroClient {
debugHeaders(`sent %O`, headers);
debugBodies(`sent %O`, body);
const rawResponse = await (customFetch || this._fetch)(fullUrl, reqOptions);
debugBasic(
`got ${rawResponse.status} ${rawResponse.headers.get('Content-Type')} ${
rawResponse.size
}b`,
);
debugHeaders(`got %O`, rawResponse.headers.raw());
debugStats(`%O`, this.requestStats);
const res = new FavroResponse<Data, this>(this, rawResponse);
this._backendId = res.backendId || this._backendId;
this._limitResetsAt = res.limitResetsAt;
this._requestsLimit = res.limit;
this._requestsRemaining = res.requestsRemaining;
debugBasic(`got ${res.status} ${res.contentType} ${rawResponse.size}b`);
debugHeaders(`got %O`, headers);
debugBodies(`got %O`, body);
debugStats(`%O`, this.requestStats);

if (this._requestsRemaining < 1 || res.status == 429) {
// TODO: Set an interval before allowing requests to go through again, OR SOMETHING
Logger.warn(
Expand All @@ -246,6 +250,7 @@ export class FavroClient {
}
this.assert(res.status < 300, `Failed with status ${res.status}`);
const parsedBody = await res.getParsedBody();
debugBodies(`got %O`, parsedBody);
if (
parsedBody &&
typeof parsedBody != 'string' &&
Expand Down

0 comments on commit bed3966

Please sign in to comment.