Skip to content

Conversation

@glasnt
Copy link
Contributor

@glasnt glasnt commented Dec 15, 2024

Description

Re-creation of fix in #12544, debugging CI issues.

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Hi team,

Gemini is currently reviewing this pull request and will provide a full review shortly. In the meantime, here's a quick summary to get everyone up to speed:

This PR, "debug: recreate change in 12544", aims to recreate a fix from PR #12544 and resolve some CI issues. The changes are focused on appengine/standard/iap/js/poll.js:

  • Copyright Update (lines 1-11): The copyright notice has been updated to reflect Google LLC.
  • Session Refresh Enhancement (lines 54-74): The checkSessionRefresh function has been modified. The fetch call now includes additional headers (method, credentials, X-Requested-With) to ensure proper session handling and identification of AJAX requests. Comments have been added to clarify the purpose of these changes. This is likely to improve the reliability of session refresh mechanisms.

Overall, this PR appears to be a straightforward fix addressing a previous issue and improving the robustness of the session management. Let me know if you have any questions.

And now, a little haiku to brighten your day:

Code flows like a stream,
Bugs are caught, the fix is in,
Software gleams anew.

@product-auto-label product-auto-label bot added samples Issues that are directly related to samples. api: appengine Issues related to the App Engine Admin API API. labels Dec 15, 2024
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

This pull request recreates a change from a previous pull request (#12544) to debug CI issues. It updates the copyright information and modifies the checkSessionRefresh function to include additional headers in the fetch request. The added headers are meant to improve the server's ability to handle sessions, specifically for AJAX requests. The changes look correct, but there are opportunities to improve clarity and style.

@@ -1,11 +1,11 @@
// Copyright Google Inc.
//
// Copyright 2017 Google LLC
Copy link

Choose a reason for hiding this comment

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

It's standard practice to omit the year in copyright notices unless the copyright has changed hands or there's a specific legal reason to include it. Consider simplifying to // Copyright Google LLC to adhere to common conventions.

Suggested change
// Copyright 2017 Google LLC
// Copyright Google LLC

Comment on lines +57 to +64
// XMLHttpRequests is used by the server to identify AJAX requests
fetch('/favicon.ico', {
method: "GET",
credentials: 'include',
headers: {
'X-Requested-With': 'XMLHttpRequest'
}
}).then(function(response) {
Copy link

Choose a reason for hiding this comment

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

low

While the added headers are helpful, the code lacks clarity on why they are necessary for AJAX request identification. Explain the purpose of X-Requested-With and how the server uses it. Mentioning the specific server-side framework or library that relies on this header would be very helpful. This adds valuable context for future maintainers and improves the overall understanding of the code.

Comment on lines 67 to 73
// No new session detected. Try to get a session again
window.setTimeout(checkSessionRefresh, 500);
} else {
// Session retrieved.
iapSessionRefreshWindow.close();
iapSessionRefreshWindow = null;
}
Copy link

Choose a reason for hiding this comment

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

low

The comments // Checking if browser has a session... and // Session retrieved could be more descriptive. Instead of simply stating what the code does, explain the significance of the check and the retrieval. For example, what does a 401 status indicate in this context? What happens after the session is retrieved? This will make the code easier to understand and maintain.

@glasnt glasnt closed this Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: appengine Issues related to the App Engine Admin API API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant