-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skipped Reporting of 302 and Request abort error #4881
base: unstable
Are you sure you want to change the base?
Conversation
export function cleanupRequests() { | ||
abortController.abort(); | ||
pendingRequests.clear(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this being used anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exported cleanupRequests
function is meant to be called when a component unmounts. It aborts any pending requests and clears the pendingRequests
set to prevent memory leaks or unwanted side effects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right! Unfortunately I don't see any usages of this function. Makes me wonder whether we really need it, particularly within the scope of this task?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! I'll go ahead and remove it.
// Reset the flag after navigation is likely complete | ||
setTimeout(() => { | ||
isNavigating = false; | ||
}, 100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the use of a delay here is a reliable way to set the navigation to false. I think it would be better to do this after an abort has been confirmed. You could consider adding an event listener to an controller.signal
instance and do the setting there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right—relying on a fixed delay is not a reliable way to reset the navigation flag. Using an event listener on the AbortController.signal
makes a lot more sense since it ensures the state update happens precisely when the abort is confirmed. I'll update as you suggested.
if ( | ||
isNavigating || | ||
isReloading || | ||
axios.isCancel(error) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's import the isCancel
instead so we can clear the linting error below ie;
import {isCancel} from 'axios'
and this line changes to isCancel(error) ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the suggestion! I'll make sure to update it accordingly.
const status = error.response?.status || 0; | ||
|
||
// Suppress contentnode query errors | ||
if (url.includes('contentnode')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about the motivation for this. The issue description doesn't seem to suggest this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The primary goal here is to suppress errors specifically related to content nodes, as they are a significant source of the issues we need to address.
- Since the URLs containing the keyword
contentnode
reliably identify these errors, this condition becomes essential for targeted error suppression. - I acknowledge that this detail should have been explicitly mentioned in the issue description.
Hi @akolson , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes seem to make sense. Thanks @SukhvirKooner. I'll invite @nucleogenesis @AlexVelezLl @ozer550 incase of any further feedback before we proceed with the approval
Fixes: #4873
Summary
Redirect requests (301/302)
Before
![Screenshot 2025-01-27 at 10 08 48 PM](https://private-user-images.githubusercontent.com/72186852/407365100-b47b66c1-e505-4f43-8269-3fcbfbe5ccff.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MzU0MjAsIm5iZiI6MTczOTYzNTEyMCwicGF0aCI6Ii83MjE4Njg1Mi80MDczNjUxMDAtYjQ3YjY2YzEtZTUwNS00ZjQzLTgyNjktM2ZjYmZiZTVjY2ZmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDE1NTg0MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZjNmE2YzBmNTMxMDA5NTYwODg5OTBlMDkzODU2ZjNjNmVmMjkzYjk5NTA0MWNlMmQyN2IyMWFhMTNmMjI5YmQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.DDar0jpWPKkotZ5NUmjRCJNG9WHR5ZkZezXMt4dmkYw)
![Screenshot 2025-01-27 at 10 09 16 PM](https://private-user-images.githubusercontent.com/72186852/407365658-c0200496-9d41-43ea-b8b3-16ba0e3c2dff.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MzU0MjAsIm5iZiI6MTczOTYzNTEyMCwicGF0aCI6Ii83MjE4Njg1Mi80MDczNjU2NTgtYzAyMDA0OTYtOWQ0MS00M2VhLWI4YjMtMTZiYTBlM2MyZGZmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDE1NTg0MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTAzN2E2NTU2MzIwYWMzYjA1OWUzMzg2NDExNWIzOWRlODNjOTlkMzFmZGYxZmUwNDg0ZDAzYmFjYzhjY2YyMWMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Lf3-GZqsifRGOLB5Rm7vuMpBpnAlK-AjxOHy5Wjrdzo)
After
I have successfully resolved the 302 redirect request issue by updating the Axios error handling logic. Specifically, I added 302 to the list of status codes that should bypass error logging:
(error.response && [302, 403, 404, 405, 412].includes(error.response.status))
This ensures that when a 302 status is returned, Axios will handle it gracefully without triggering unnecessary error logs or forwarding it to Sentry.
Request aborted Error
Error ScreenShort
![Screenshot 2025-01-28 at 12 39 33 PM](https://private-user-images.githubusercontent.com/72186852/407369811-db6b0579-3fac-4dab-846d-e1f10669dfa1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MzU0MjAsIm5iZiI6MTczOTYzNTEyMCwicGF0aCI6Ii83MjE4Njg1Mi80MDczNjk4MTEtZGI2YjA1NzktM2ZhYy00ZGFiLTg0NmQtZTFmMTA2NjlkZmExLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDE1NTg0MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNmZGY4OGNjMzBmNTM2ZjdmNTAzOGJjMjM3NjdlOGNkNTk1OTQzYjZjZDU5MmI5ZDU5YTYxNjIxNDA5MTFhM2YmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.q74GMQaQee_qZ9_CCxWY7Ew-HGy0C1211D7jd6djdLs)
I have made the key changes to the original code to handle the Error particular during navigation:
const abortController = new AbortController();
Despite these suppression mechanisms, legitimate errors unrelated to Request aborted or Redirect requests (301/302) will still be logged and captured in Sentry for further monitoring and troubleshooting.