Skip to content

Commit f2fef08

Browse files
authored
fix: do not log initiated requests and successful responses (#5304)
1 parent e22512b commit f2fef08

File tree

10 files changed

+24
-76
lines changed

10 files changed

+24
-76
lines changed

.changeset/wild-horses-swim.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@graphql-hive/apollo': patch
3+
'@graphql-hive/core': patch
4+
'@graphql-hive/yoga': patch
5+
'@graphql-hive/cli': patch
6+
---
7+
8+
Fixed a logging issue where both initiated requests and successful responses were being recorded. This was causing the logs to be filled with unnecessary information and affected `hive artifact:fetch --artifact` command.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const version = '0.33.4';
1+
export const version = '0.34.0';

packages/libraries/core/src/client/http-client.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface SharedConfig {
1818
/**
1919
* Function for determining whether the request response is okay.
2020
* You can override it if you want to accept other status codes as well.
21-
* @default {response => response.ok}
21+
* @default (response) => response.ok
2222
**/
2323
isRequestOk?: ResponseAssertFunction;
2424
}
@@ -75,7 +75,7 @@ export async function makeFetchCall(
7575
/**
7676
* Function for determining whether the request response is okay.
7777
* You can override it if you want to accept other status codes as well.
78-
* @default {response => response.ok}
78+
* @default (response) => response.ok
7979
**/
8080
isRequestOk?: ResponseAssertFunction;
8181
},
@@ -96,11 +96,6 @@ export async function makeFetchCall(
9696

9797
return await asyncRetry(
9898
async (bail, attempt) => {
99-
logger.info(
100-
`${config.method} ${endpoint}` +
101-
(retries > 0 ? ' ' + getAttemptMessagePart(attempt, retries + 1) : ''),
102-
);
103-
10499
const getDuration = measureTime();
105100
const signal = AbortSignal.timeout(config.timeout ?? 20_000);
106101

@@ -130,10 +125,6 @@ export async function makeFetchCall(
130125
});
131126

132127
if (isRequestOk(response)) {
133-
logger.info(
134-
`${config.method} ${endpoint} succeeded with status ${response.status} ${getDuration()}.`,
135-
);
136-
137128
return response;
138129
}
139130

@@ -176,10 +167,6 @@ function getErrorMessage(error: unknown): string {
176167
return '<no error message>';
177168
}
178169

179-
function getAttemptMessagePart(attempt: number, retry: number): string {
180-
return `Attempt (${attempt}/${retry})`;
181-
}
182-
183170
function measureTime() {
184171
const start = Date.now();
185172
return () => '(' + formatTimestamp(Date.now() - start) + ')';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const version = '0.5.0';
1+
export const version = '0.6.0';

packages/libraries/core/tests/http-client.spec.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ test('HTTP call without retries and system level error', async () => {
1515
}
1616

1717
expect(logger.getLogs()).toMatchInlineSnapshot(`
18-
[INF] GET https://ap.localhost.noop
1918
[ERR] Error: getaddrinfo ENOTFOUND ap.localhost.noop
2019
[ERR] GET https://ap.localhost.noop failed (666ms). getaddrinfo ENOTFOUND ap.localhost.noop
2120
`);
@@ -33,10 +32,8 @@ test('HTTP with retries and system', async () => {
3332
}).catch(_ => {});
3433

3534
expect(logger.getLogs()).toMatchInlineSnapshot(`
36-
[INF] GET https://ap.localhost.noop Attempt (1/2)
3735
[ERR] Error: getaddrinfo ENOTFOUND ap.localhost.noop
3836
[ERR] GET https://ap.localhost.noop failed (666ms). getaddrinfo ENOTFOUND ap.localhost.noop
39-
[INF] GET https://ap.localhost.noop Attempt (2/2)
4037
[ERR] Error: getaddrinfo ENOTFOUND ap.localhost.noop
4138
[ERR] GET https://ap.localhost.noop failed (666ms). getaddrinfo ENOTFOUND ap.localhost.noop
4239
`);
@@ -60,7 +57,6 @@ test('HTTP with 4xx status code will not be retried', async () => {
6057
}).catch(_ => {});
6158

6259
expect(logger.getLogs()).toMatchInlineSnapshot(`
63-
[INF] GET https://ap.localhost.noop Attempt (1/2)
6460
[ERR] GET https://ap.localhost.noop failed with status 404 (666ms): Bubatzbieber
6561
[ERR] Abort retry because of status code 404.
6662
`);
@@ -85,9 +81,7 @@ test('HTTP with 5xx status code will be retried', async () => {
8581
}).catch(_ => {});
8682

8783
expect(logger.getLogs()).toMatchInlineSnapshot(`
88-
[INF] GET https://ap.localhost.noop Attempt (1/2)
8984
[ERR] GET https://ap.localhost.noop failed with status 500 (666ms): Bubatzbieber
90-
[INF] GET https://ap.localhost.noop Attempt (2/2)
9185
[ERR] GET https://ap.localhost.noop failed with status 500 (666ms): Bubatzbieber
9286
[ERR] GET https://ap.localhost.noop retry limit exceeded after 2 attempts.
9387
`);
@@ -112,9 +106,7 @@ test('HTTP with status 3xx will be retried', async () => {
112106
}).catch(_ => {});
113107

114108
expect(logger.getLogs()).toMatchInlineSnapshot(`
115-
[INF] GET https://ap.localhost.noop Attempt (1/2)
116109
[ERR] GET https://ap.localhost.noop failed with status 302 (666ms): Bubatzbieber
117-
[INF] GET https://ap.localhost.noop Attempt (2/2)
118110
[ERR] GET https://ap.localhost.noop failed with status 302 (666ms): Bubatzbieber
119111
[ERR] GET https://ap.localhost.noop retry limit exceeded after 2 attempts.
120112
`);
@@ -139,8 +131,6 @@ test('HTTP with status 3xx will not be retried with custom "isRequestOk" impleme
139131
isRequestOk: response => response.status === 302,
140132
}).catch(_ => {});
141133

142-
expect(logger.getLogs()).toMatchInlineSnapshot(`
143-
[INF] GET https://ap.localhost.noop Attempt (1/2)
144-
[INF] GET https://ap.localhost.noop succeeded with status 302 (666ms).
145-
`);
134+
// Make sure that the 3xx status code is not retried.
135+
expect(logger.getLogs()).toMatchInlineSnapshot(``);
146136
});

packages/libraries/core/tests/reporting.spec.ts

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ test('should not leak the exception', async () => {
5050

5151
expect(logger.getLogs()).toMatchInlineSnapshot(`
5252
[INF] [hive][reporting] Publish schema
53-
[INF] [hive][reporting] POST http://127.0.0.1:55404 Attempt (1/6)
5453
[ERR] [hive][reporting] Error: connect ECONNREFUSED 127.0.0.1:55404
5554
[ERR] [hive][reporting] at TCPConnectWrap.afterConnect [as oncomplete] (node:net:666:666)
5655
[ERR] [hive][reporting] POST http://127.0.0.1:55404 failed (666ms). connect ECONNREFUSED 127.0.0.1:55404
@@ -125,8 +124,6 @@ test('should send data to Hive', async () => {
125124

126125
expect(logger.getLogs()).toMatchInlineSnapshot(`
127126
[INF] [hive][reporting] Publish schema
128-
[INF] [hive][reporting] POST http://localhost/200 Attempt (1/6)
129-
[INF] [hive][reporting] POST http://localhost/200 succeeded with status 200 (666ms).
130127
[INF] [hive][reporting] Published schema
131128
`);
132129
});
@@ -198,8 +195,6 @@ test('should send data to Hive (deprecated endpoint)', async () => {
198195

199196
expect(logger.getLogs()).toMatchInlineSnapshot(`
200197
[INF] [hive][reporting] Publish schema
201-
[INF] [hive][reporting] POST http://localhost/200 Attempt (1/6)
202-
[INF] [hive][reporting] POST http://localhost/200 succeeded with status 200 (666ms).
203198
[INF] [hive][reporting] Published schema
204199
`);
205200

@@ -273,8 +268,6 @@ test('should send data to app.graphql-hive.com/graphql by default', async () =>
273268

274269
expect(logger.getLogs()).toMatchInlineSnapshot(`
275270
[INF] [hive][reporting] Publish schema
276-
[INF] [hive][reporting] POST https://app.graphql-hive.com/graphql Attempt (1/6)
277-
[INF] [hive][reporting] POST https://app.graphql-hive.com/graphql succeeded with status 200 (666ms).
278271
[INF] [hive][reporting] Published schema
279272
`);
280273

@@ -348,11 +341,9 @@ test('should send data to Hive immediately', async () => {
348341
expect(logger.getLogs()).toMatchInlineSnapshot(`[INF] [hive][reporting] Publish schema`);
349342
logger.clear();
350343
await waitFor(50);
351-
expect(logger.getLogs()).toMatchInlineSnapshot(`
352-
[INF] [hive][reporting] POST http://localhost/200 Attempt (1/6)
353-
[INF] [hive][reporting] POST http://localhost/200 succeeded with status 200 (666ms).
354-
[INF] [hive][reporting] Successfully published schema
355-
`);
344+
expect(logger.getLogs()).toMatchInlineSnapshot(
345+
`[INF] [hive][reporting] Successfully published schema`,
346+
);
356347
expect(body.variables.input.sdl).toBe(`type Query{foo:String}`);
357348
expect(body.variables.input.author).toBe(author);
358349
expect(body.variables.input.commit).toBe(commit);
@@ -361,11 +352,9 @@ test('should send data to Hive immediately', async () => {
361352
expect(body.variables.input.force).toBe(true);
362353

363354
await waitFor(100);
364-
expect(logger.getLogs()).toMatchInlineSnapshot(`
365-
[INF] [hive][reporting] POST http://localhost/200 Attempt (1/6)
366-
[INF] [hive][reporting] POST http://localhost/200 succeeded with status 200 (666ms).
367-
[INF] [hive][reporting] Successfully published schema
368-
`);
355+
expect(logger.getLogs()).toMatchInlineSnapshot(
356+
`[INF] [hive][reporting] Successfully published schema`,
357+
);
369358

370359
await hive.dispose();
371360
http.done();
@@ -433,8 +422,6 @@ test('should send original schema of a federated (v1) service', async () => {
433422
const logs = logger.getLogs();
434423
expect(logs).toMatchInlineSnapshot(`
435424
[INF] [hive][reporting] Publish schema
436-
[INF] [hive][reporting] POST http://localhost/200 Attempt (1/6)
437-
[INF] [hive][reporting] POST http://localhost/200 succeeded with status 200 (666ms).
438425
[INF] [hive][reporting] Published schema
439426
`);
440427
http.done();
@@ -502,8 +489,6 @@ test('should send original schema of a federated (v2) service', async () => {
502489
const logs = logger.getLogs();
503490
expect(logs).toMatchInlineSnapshot(`
504491
[INF] [hive][reporting] Publish schema
505-
[INF] [hive][reporting] POST http://localhost/200 Attempt (1/6)
506-
[INF] [hive][reporting] POST http://localhost/200 succeeded with status 200 (666ms).
507492
[INF] [hive][reporting] Published schema
508493
`);
509494
http.done();
@@ -563,8 +548,6 @@ test('should display SchemaPublishMissingServiceError', async () => {
563548

564549
expect(logger.getLogs()).toMatchInlineSnapshot(`
565550
[INF] [hive][reporting] Publish schema
566-
[INF] [hive][reporting] POST http://localhost/200 Attempt (1/6)
567-
[INF] [hive][reporting] POST http://localhost/200 succeeded with status 200 (666ms).
568551
[ERR] [hive][reporting] Failed to report schema: Service name is not defined
569552
`);
570553
});
@@ -624,12 +607,9 @@ test('should display SchemaPublishMissingUrlError', async () => {
624607

625608
expect(logger.getLogs()).toMatchInlineSnapshot(`
626609
[INF] [hive][reporting] Publish schema
627-
[INF] [hive][reporting] POST http://localhost/200 Attempt (1/6)
628-
[INF] [hive][reporting] POST http://localhost/200 succeeded with status 200 (666ms).
629610
[ERR] [hive][reporting] Failed to report schema: Service url is not defined
630611
`);
631612

632-
expect(logger.getLogs()).toContain('POST http://localhost/200 Attempt (1/6)');
633613
expect(logger.getLogs()).toContain('Service url is not defined');
634614
});
635615

@@ -677,7 +657,6 @@ test('retry on non-200', async () => {
677657

678658
expect(logger.getLogs()).toMatchInlineSnapshot(`
679659
[INF] [hive][reporting] Publish schema
680-
[INF] [hive][reporting] POST http://localhost/registry Attempt (1/6)
681660
[ERR] [hive][reporting] Error: connect ECONNREFUSED ::1:80
682661
[ERR] [hive][reporting] at createConnectionError (node:net:666:666)
683662
[ERR] [hive][reporting] at afterConnectMultiple (node:net:666:666)

packages/libraries/core/tests/usage.spec.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ test('should send data to Hive', async () => {
167167
expect(logger.getLogs()).toMatchInlineSnapshot(`
168168
[INF] [hive][usage] Disposing
169169
[INF] [hive][usage] Sending report (queue 1)
170-
[INF] [hive][usage] POST http://localhost/200
171-
[INF] [hive][usage] POST http://localhost/200 succeeded with status 200 (666ms).
172170
[INF] [hive][usage] Report sent!
173171
`);
174172

@@ -273,8 +271,6 @@ test('should send data to Hive (deprecated endpoint)', async () => {
273271
expect(logger.getLogs()).toMatchInlineSnapshot(`
274272
[INF] [hive][usage] Disposing
275273
[INF] [hive][usage] Sending report (queue 1)
276-
[INF] [hive][usage] POST http://localhost/200
277-
[INF] [hive][usage] POST http://localhost/200 succeeded with status 200 (666ms).
278274
[INF] [hive][usage] Report sent!
279275
`);
280276

@@ -358,7 +354,6 @@ test('should not leak the exception', async () => {
358354

359355
expect(logger.getLogs()).toMatchInlineSnapshot(`
360356
[INF] [hive][usage] Sending report (queue 1)
361-
[INF] [hive][usage] POST http://404.localhost.noop Attempt (1/2)
362357
[ERR] [hive][usage] Error: getaddrinfo ENOTFOUND 404.localhost.noop
363358
[ERR] [hive][usage] at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:666:666)
364359
[ERR] [hive][usage] POST http://404.localhost.noop failed (666ms). getaddrinfo ENOTFOUND 404.localhost.noop
@@ -425,8 +420,6 @@ test('sendImmediately should not stop the schedule', async () => {
425420

426421
expect(logger.getLogs()).toMatchInlineSnapshot(`
427422
[INF] [hive][usage] Sending report (queue 1)
428-
[INF] [hive][usage] POST http://localhost/200
429-
[INF] [hive][usage] POST http://localhost/200 succeeded with status 200 (666ms).
430423
[INF] [hive][usage] Report sent!
431424
`);
432425
logger.clear();
@@ -438,17 +431,13 @@ test('sendImmediately should not stop the schedule', async () => {
438431
expect(logger.getLogs()).toMatchInlineSnapshot(`
439432
[INF] [hive][usage] Sending immediately
440433
[INF] [hive][usage] Sending report (queue 2)
441-
[INF] [hive][usage] POST http://localhost/200
442434
`);
443435
logger.clear();
444436
await waitFor(100);
445437
// Let's check if the scheduled send task is still running
446438
await collect(args, {});
447439
await waitFor(30);
448-
expect(logger.getLogs()).toMatchInlineSnapshot(`
449-
[INF] [hive][usage] POST http://localhost/200 succeeded with status 200 (666ms).
450-
[INF] [hive][usage] Report sent!
451-
`);
440+
expect(logger.getLogs()).toMatchInlineSnapshot(`[INF] [hive][usage] Report sent!`);
452441

453442
await hive.dispose();
454443
http.done();
@@ -542,8 +531,6 @@ test('should send data to Hive at least once when using atLeastOnceSampler', asy
542531
expect(logger.getLogs()).toMatchInlineSnapshot(`
543532
[INF] [hive][usage] Disposing
544533
[INF] [hive][usage] Sending report (queue 2)
545-
[INF] [hive][usage] POST http://localhost/200
546-
[INF] [hive][usage] POST http://localhost/200 succeeded with status 200 (666ms).
547534
[INF] [hive][usage] Report sent!
548535
`);
549536

@@ -646,8 +633,6 @@ test('should not send excluded operation name data to Hive', async () => {
646633
expect(logger.getLogs()).toMatchInlineSnapshot(`
647634
[INF] [hive][usage] Disposing
648635
[INF] [hive][usage] Sending report (queue 2)
649-
[INF] [hive][usage] POST http://localhost/200
650-
[INF] [hive][usage] POST http://localhost/200 succeeded with status 200 (666ms).
651636
[INF] [hive][usage] Report sent!
652637
`);
653638

@@ -744,7 +729,6 @@ test('retry on non-200', async () => {
744729

745730
expect(logger.getLogs()).toMatchInlineSnapshot(`
746731
[INF] [hive][usage] Sending report (queue 1)
747-
[INF] [hive][usage] POST http://localhost/200 Attempt (1/2)
748732
[ERR] [hive][usage] POST http://localhost/200 failed with status 500 (666ms): No no no
749733
[INF] [hive][usage] Disposing
750734
`);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const version = '0.33.3';
1+
export const version = '0.33.4';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const version = '0.33.3';
1+
export const version = '0.34.0';

packages/libraries/yoga/tests/yoga.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ test('should not interrupt the process', async () => {
9999
},
100100
}),
101101
);
102-
await waitFor(50);
102+
await waitFor(100);
103103

104104
const reportingLogs = logger
105105
.getLogs()

0 commit comments

Comments
 (0)