- Add waitingTimeout property to CacheProperties for configurable timeout
- Extract timeout logic to waiting-timeout.ts utility function
- Store request ID outside timeout callback to allow earlier GC
- Add unref() to timeout in Node.js to prevent keeping process alive
- Fix timeout logic to handle axios default timeout of 0
- Only create timeout when explicitly configured or config.timeout > 0
Changes address comments 2598940999, 2598944866, and 2598947753.
Co-authored-by: arthurfiorette <47537704+arthurfiorette@users.noreply.github.com>
- Add timeout mechanism to automatically clean up waiting entries after axios timeout period
- Use axios config timeout or default to 30 seconds if not configured
- This prevents memory leaks when entries are evicted from storage before response completes
- Updated tests to use short timeouts and wait for cleanup to complete
Note: This implements the approach requested by @arthurfiorette to use axios timeout
instead of immediately resolving/rejecting waiting entries when cache state is not loading.
Co-authored-by: arthurfiorette <47537704+arthurfiorette@users.noreply.github.com>
* feature: added stale flag in request return object
* feature: added stale flag in request return object
* feat: added stale flag in request return object
* feat: added stale flag in request return object
* chore: fixed lint issues
* refactor: change id generation location
* fix: lint
* refactor: ensures id will be created only if cache is not false
* chore(deps-dev): bump vitepress from 1.0.0-beta.5 to 1.0.0-beta.6 (#618)
* chore(deps-dev): bump @types/node from 18.16.19 to 18.17.0 (#617)
* chore(deps-dev): bump tslib from 2.6.0 to 2.6.1 (#619)
* chore(deps-dev): bump @types/node from 18.17.0 to 18.17.1 (#620)
* chore: dependabot
* ci: dependabot
* feat: handle non axios errors rejections (#609)
* fix: correct config re throw
* chore(deps-dev): bump eslint-config-prettier from 8.8.0 to 8.9.0 (#624)
* chore(deps-dev): bump jest from 29.6.1 to 29.6.2 (#622)
* feat: turn most types into interfaces (#615)
* Turn most types into interfaces
* Turn 'CacheAxiosResponse' into a interface
* Update docs
* Change docs to be more didactic
* chore(deps-dev): bump jest-environment-jsdom from 29.6.1 to 29.6.2 (#623)
* chore: removed unused eslint comment
* feat: handle errors on object-code
* feat: bring back ids
* chore: lint
---------
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Arthur Fiorette <arthur.fiorette@gmail.com>
Co-authored-by: Denis Rossati <denis.rossatiramos@gmail.com>
* feat(WIP): etag and if-modified-since support
* test: fixed test name
* fix: merge response headers
* test: add etag / last-modified tests
* test: add must-revalidate tests
* fix: handle expirationTime 0 as true.
* tests: refactored some tests
* test: added keepIfStale tests
* fix: remove axios error for 304 requests
* fix: possible infinite loop on validateStatus function
* tests: ignore code that is hard test from coverage
* fix: use Last-Modified header for modifiedSince
If-Modified-Since is never sent by a server, it's
a client only header. However Last-Modified is sent
by the server to indicate the last time the returned
version was modified (it might not be the last version
depending on cache configuration on intermediate
servers)
* test: use validateStatus in mock
This more closely match default axios adapter.
* fix: validateStatus handling all cases
* refactor: use cache.createdAt if the last-modified header isn't present
* test: etag with predefined value
* test: added more test cases
* fix: fixed logic in some tests
* docs: initial documentation
* fix: manual values work out of the box
This removes header requirement from server.
* docs: add details to etag and modifiedSince features
* fix: delete custom headers from response
* feat: accept all configurations from global axios
Merging global into local configuration enable user
to use global configuration for all options and remove
the need to check local and global values every time.
* fix: preserve original types from AxiosInstance
The only value axios needs is a URL, and in the second definition of the method, there is already a URL parameter, so it can be undefined.
* Fix: defaults modifiedSince back to false.
Avoids breaking changes.
* docs: fix etag examples
* docs: document internal headers
* refactor: ternary operator :)
* style: prettified code
* test: remove modifiedSince: false in tests since this is the default
* docs: fix headers examples
* docs: fixed example formatting
* tests: split tests into multiple files to test them faster
* docs: correct jsdoc empty object
Co-authored-by: Charly Koza <cka@f4-group.com>