Feat: Create / Add Axios Large Response Interceptor#5
Feat: Create / Add Axios Large Response Interceptor#5alexmarqs merged 20 commits intoepilot-dev:mainfrom
Conversation
- Add comprehensive types for interceptor configuration - Implement utility functions for large payload fetching - Update interceptor to support dynamic configuration - Add debug logging and error handling - Expose new export for types and interceptor function
- Rename types and functions for clarity - Add `enabled` option to conditionally apply interceptor - Support custom large payload fetching strategy - Update namespace and default options - Enhance type safety and configuration flexibility
- Create comprehensive test cases for axios large response interceptor - Add test configuration for Vitest - Implement initial test scenarios for request and response interceptors - Verify basic functionality and configuration options
- Add comprehensive test cases for global and custom configuration scenarios - Verify interceptor behavior with different response types - Improve test coverage for request and response interceptors - Enhance test suite with more detailed assertions
- Add test cases for per-request and global option configurations - Verify interceptor behavior with custom header flags and ref properties - Improve test suite with more nuanced option merging and handling scenarios - Expand assertions for large response interceptor functionality
…p new release version
|
Hey @alexmarqs, I have a fundamental request here, can we switch to not send large response accepts by default?
I think it should be the other way around. By default it should fail, it's not ok to have APIs return over 6MB of data, demonstrates likely a bad design in the code. Would be nice for teams to inspect the failure and then decide to make it enabled:true. We should not have to do this (should be the default): |
Hey @jpinho I totally get your point, I thought about that when designing this but ended up with the default being enabled. Happy to have your feedback here and I will change this based on that 🙂! |
Yep, that also crossed my mind. It's just that enabling this will bloat our browsers caches, and slow down our MFEs greatly => in a super easy way. We should log a warning for large responses on the client and make it default:false so that the change is explicit. Otherwise a distracted developer may start using our clients and pulling large response without even realising. We want the engineers to deal with the failure first, and only then use this as a tool to temporarily mitigate if required. Often the solution is to fix the bad code pulling such large responses. |
- Add `disableWarnings` option to control usage warnings - Change default `enabled` option to `false` - Implement usage warnings for unset interceptor configuration - Update types and documentation to reflect new default behavior - Enhance flexibility of interceptor configuration
|
@jpinho I have committed some changes based on your feedback, here is: 0383366
If all good, I will create a new release and bump the version and then merge. If not, let's keep iterating on this! |
Co-authored-by: João Pinho <jpe.pinho@gmail.com>
| ...DEFAULT_OPTIONS, | ||
| ...globalOptions, | ||
| ...configRequestOptions, | ||
| } satisfies AxiosLargeResponseOptions; |
An Axios interceptor designed to handle large responses.