Skip to content

Use async fetch in crosslink redirect checks - #7603

Queued
dagnir wants to merge 1 commit into
masterfrom
dongie/crosslink-async-fetch
Queued

dagnir wants to merge 1 commit into
masterfrom
dongie/crosslink-async-fetch

Conversation

@dagnir

@dagnir dagnir commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation and Context

Fix incorrect redirects from AWS docs page to javadoc, for example https://docs.aws.amazon.com/goto/SdkForJavaV2/s3-2006-03-01/PutObject which should redirect to https://docs.aws.amazon.com/java/api/latest/software/amazon/awssdk/services/s3/S3Client.html#putObject(software.amazon.awssdk.services.s3.model.PutObjectRequest).

The way we check whether a target javadoc page is via sync XHR. Unfortunately, this breaks in instances where browser plugins or similar wraps XHR and modify its behavior, specifically w.r.t. to the returned status code.

Modifications

This change updates the crosslink_redirect.html page to use the fetch() API instead of XHR.

Testing

Tested locally with a test webserver.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance improvement (non-breaking change which improves latency, throughput, or resource use)
  • Deprecation (marks existing functionality as deprecated)
  • Removal (removes previously deprecated functionality)
  • Documentation (changes to documentation only)
  • Other (tests, build, CI, or refactoring with no customer-visible change)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

AI tools

  • I wrote this pull request description myself, not with an AI tool
  • I have reviewed all changes in this pull request myself, including any generated by AI tools

License

  • I confirm that this pull request can be released under the Apache 2 license

Replace the synchronous XMLHttpRequest in checkResourceExists with an
async fetch. Some browser extensions wrap XMLHttpRequest, and the
wrapped synchronous requests report status 0. Both existence checks
then fail and every crosslink falls back to the API index page instead
of the model or client page.

Move the redirect resolution into an async function and navigate once
it resolves. Cancel the response body after reading the status so the
check does not download large pages such as S3Client.html.
@dagnir
dagnir requested a review from a team as a code owner December 1, 2026 20:58
@dagnir
dagnir requested a review from S-Saranya1 December 1, 2026 21:26
@dagnir
dagnir enabled auto-merge December 4, 2026 21:35
@dagnir
dagnir added this pull request to the merge queue Dec 4, 2026
Any commits made after this event will not be merged.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants