Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

DEVPROD-2643: Fix useLogDownloader bug #436

Merged
merged 7 commits into from
Nov 28, 2023

Conversation

sophstad
Copy link
Collaborator

@sophstad sophstad commented Nov 15, 2023

DEVPROD-2643

Description

  • First commit reverts Revert "DEVPROD-929: Use task log links from API" #434 i. e. reintroduces DEVPROD-929: Use task log links from API #431
  • Second commit fixes bug
    • Remove useLogDownloader dependency on isEvergreenLoading. This dependency caused the hook to run multiple times; when the bug was deployed to production you could observe multiple requests to Logkeeper. I think the subsequent request to Logkeeper also resulted in the first one being terminated, hence the "Incomplete log" warnings we saw earlier today.
    • In the case of an invalid task URL (i.e. /evergreen/invalid/0/task) where the GraphQL query doesn't return a download link, use the previous approach to construct a link given the task ID, execution, etc.

Testing

  • Verified on beta that removing this dependency results in a single call to fetch the log. It's deployed to beta right now if you care to look!

Copy link

cypress bot commented Nov 15, 2023

1 failed test on run #4226 ↗︎

1 123 0 0 Flakiness 0
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.

Details:

Clean up
Project: Parsley Commit: dbf8182f82
Status: Failed Duration: 03:49 💡
Started: Nov 28, 2023 10:11 PM Ended: Nov 28, 2023 10:15 PM

Review all test suite changes for PR #436 ↗︎

@sophstad sophstad changed the title Revert "Revert "DEVPROD-929: Use task log links from API"" DEVPROD-2643: Fix useLogDownloader bug Nov 15, 2023
@sophstad sophstad requested a review from a team November 15, 2023 16:19
@sophstad sophstad marked this pull request as ready for review November 15, 2023 16:19
Copy link
Collaborator

@minnakt minnakt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for the late review 😭 pls ping me directly whenever you want a re-review!

Comment on lines 177 to 178
await waitForNextUpdate();
await waitForNextUpdate();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the double await here strikes me as odd... could it be removed? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake thank you!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if this is a problem on my end, but when I run this test suite a few times locally I see quite a bit of flakiness. I also tried switching to the main branch and running the test suite a bunch of times, but I didn't see any flakiness there

options: { priority?: boolean; text?: boolean }
logLinks: TaskType["logs"],
origin: string,
params: { [key: string]: any } = {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it make sense to type the params a bit more strongly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed to be the general typing we use for query params, à la useQueryParams

(params: { [key: string]: any }) => {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it might be nice to type with options: { priority?: boolean; text?: boolean } since we know what params to expect and constructEvergreenTaskLogURL has that type definition!

@@ -17,28 +17,35 @@ import {
import { fetchLogFile } from "utils/fetchLogFile";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not a big deal, but do you know where this flash of 0 comes from? (only happens on bigger logs)

Screen.Recording.2023-11-16.at.11.09.32.PM.mov

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think this is a React strict-mode quirk that occurs locally and results in certain things firing twice! We've been running into more of those lately. I can reproduce this on main when running locally, and don't see the behavior when my branch is deployed to beta.

@@ -142,6 +150,8 @@ const useLogDownloader = (
});
setIsLoading(false);
});
} else if (url === null) {
setError("Log URL not specified, unable to download.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think i might tweak the wording here to something along the lines of this:

Suggested change
setError("Log URL not specified, unable to download.");
setError("Could not retrieve log URL from task, unable to download.");

@sophstad sophstad requested a review from minnakt November 28, 2023 18:15
Copy link
Collaborator

@minnakt minnakt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

options: { priority?: boolean; text?: boolean }
logLinks: TaskType["logs"],
origin: string,
params: { [key: string]: any } = {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it might be nice to type with options: { priority?: boolean; text?: boolean } since we know what params to expect and constructEvergreenTaskLogURL has that type definition!

Comment on lines 162 to 177
: constructEvergreenTaskLogURL(taskID, execution, origin as any, {
priority: true,
text: true,
});
rawLogURL = task?.logs
? getEvergreenTaskLogURL(task.logs, origin, {
text: true,
})
: constructEvergreenTaskLogURL(taskID, execution, origin as any, {
text: true,
});
htmlLogURL = task?.logs
? getEvergreenTaskLogURL(task.logs, origin, {
text: false,
})
: constructEvergreenTaskLogURL(taskID, execution, origin as any, {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering if it makes sense to copy the types for getEvergreenTaskLogURL to remove the origin as any stuff!

@@ -184,7 +254,7 @@ const getEmptyTestLogURLMock: ApolloMock<
variables: {
execution: 0,
taskID: "a-task-id",
testName: "^a-test-name$",
testName: "^a-test-name-that-doesnt-exist$",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty for fixing 😁

@sophstad sophstad merged commit 1e71b12 into main Nov 28, 2023
2 checks passed
@sophstad sophstad deleted the revert-434-revert-431-DEVPROD-929 branch November 28, 2023 22:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants