75 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
183f086704 Address PR feedback: Add configurable waitingTimeout and improve implementation
- 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>
2025-12-08 15:12:46 +00:00
copilot-swe-agent[bot]
b1b0eea50b Implement timeout-based cleanup for waiting entries
- 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>
2025-12-08 13:58:15 +00:00
Arthur Fiorette
2c8910b848
Update Cache-Control header to prevent caching (#1091) 2025-09-15 12:36:51 -03:00
Arthur Fiorette
186d294b6d
chore: remove console.log 2025-08-21 12:52:31 -03:00
Arthur Fiorette
9a553a39a7
style: fix linting issues 2025-08-21 12:51:43 -03:00
Arthur Fiorette
eefd2728c7
tag: v1.8.1 2025-08-21 12:46:04 -03:00
Thomas Kam
6ca387efd9
Feature: whitelist paths (#1008)
Co-authored-by: thomassth <8331853+thomassth@users.noreply.github.com>
2025-04-27 13:58:35 -03:00
Arthur Fiorette
ff5589f9fb
fix: typing issues with axios >= 11.7.8 (#953) 2025-03-17 23:49:55 -03:00
Arthur Fiorette
a7a4e31e57
fix: cloneData for concurrent requests (#921)
* code

* code

* reuse my biome config

* fix breaking change on 1.6.0

* lint
2024-10-18 11:09:15 -03:00
Kevin Foniciello
75aa9cfefd
feat: add stale flag in request return object (#843)
* 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
2024-08-03 20:52:56 -03:00
Edwin Veldhuizen
6cba59cc1c
[must-revalidate] properly revalidate based on eTag (#824)
* [must-revalidate] implement logic to properly revalidate requests with must-revalidate cache-control header

* [lint] fix sorting of imports

* [pull 824] apply feedback

---------

Co-authored-by: Edwin Veldhuizen <edwin@pxr.nl>
2024-04-23 13:06:04 -03:00
Amrendra Kumar
0214ec682c
fix: transformResponse running twice on cached requests (#775) 2024-01-18 23:54:44 -03:00
Arthur Fiorette
ed99d775bb
feat: correct ESM and CJS support, move to microbundle. (#764) 2024-01-18 23:48:33 -03:00
Sujeet Kc
05712980df
Ådd feature to blacklist some paths (#754)
* add feature to blacklist some paths

* format with biome

* update exclude attr definition

* improvements

* style: formatted code

* fix: lint

---------

Co-authored-by: Arthur Fiorette <me@arthur.place>
2023-12-23 17:40:05 -03:00
Arthur Fiorette
a890fc2a8c
fix: support for URLSearchParams 2023-12-13 12:19:06 -03:00
Arthur Fiorette
8d03709482
feat: pinned dependencies 2023-12-12 16:20:57 -03:00
Arthur Fiorette
ecbc27e466
style: linted code 2023-11-16 03:26:37 -03:00
Arthur Fiorette
37e2f1e85a
chore: migrated to biomejs.dev 2023-11-16 03:26:20 -03:00
Arthur Fiorette
16e51e788b
feat: prefer noop over undefined when debugging 2023-09-30 15:03:21 -03:00
Arthur Fiorette
dd8f634d75
feat: testing with tsx and c8 2023-09-30 14:57:22 -03:00
arthurfiorette
130ef0d306
fix: infinite loading states when a restart occurs in the middle of a request. (#612) 2023-09-03 18:53:26 -03:00
José
e2b73e1c3a
fix: avoid RangeError: Maximum call stack size exceeded on streams and other objects (#616)
* 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>
2023-07-30 03:39:36 -03:00
arthurfiorette
683dbe0f22
fix: support max-stale on header interpreter (#543) 2023-06-09 13:10:06 -03:00
arthurfiorette
384c6b59ee
feat: hydrate option #469 2023-02-17 12:09:00 -03:00
arthurfiorette
eddff579c5
fix: axios headers 2023-02-02 20:14:46 -03:00
arthurfiorette
7d82c5a46f
feat: cache takeover #437 2022-12-25 16:56:25 -03:00
arthurfiorette
67819a3d78 refactor: dependencies, lint and null assertions 2022-08-24 07:36:29 -03:00
arthurfiorette
268fccb935
feat: override cache option 2022-06-05 11:26:00 -03:00
arthurfiorette
623ae22053
refactor: updated some minor things 2022-05-07 15:08:52 -03:00
Arthur Fiorette
17682ca0b9
Pass currentRequest on each access to storages (#220) (#226)
* feat: initial working code

* fix: better usage of currentRequest on storages

* feat: added tests
2022-05-01 10:03:30 -03:00
arthurfiorette
0a00778065
fix: fixed bug when a pending request had it cached empty (#165) 2022-03-24 19:03:40 -03:00
arthurfiorette
098cf47d06
refactor: added debug points 2022-01-23 18:12:14 -03:00
arthurfiorette
edb32bdea3
feat: add staleIfError support 2022-01-18 12:06:20 -03:00
arthurfiorette
0e2508c020
refactor: use Object.freeze at Header enum 2022-01-15 21:42:46 -03:00
arthurfiorette
e391f5664c
refactor: Header as const and renaming... 2022-01-15 12:22:12 -03:00
arthurfiorette
fa2c6e3204
perf: only execute one generateKey per request 2022-01-13 21:23:36 -03:00
Arthur Fiorette
4734c5f7a8
build: Yarn v2 and ESM & CJS bundles (#114) 2022-01-13 18:57:50 -03:00
arthurfiorette
ff73ad5c69
fix: await unawaited promises and eslint more severe 2022-01-10 13:30:31 -03:00
arthurfiorette
88d45cc0fb
feat: cache predicate now supports async functions 2022-01-10 13:00:35 -03:00
arthurfiorette
1b93070db4
refactor: used triple equal sign 2022-01-09 13:33:44 -03:00
arthurfiorette
f30e2622dd
refactor: removed "abstract" buildInterceptor function 2022-01-08 12:56:55 -03:00
arthurfiorette
cd2f14c446
refactor: removed classes to decrease bundle size 2022-01-08 12:27:52 -03:00
arthurfiorette
ce2f5976bc
fix: proper generic usage to type deep properties 2022-01-04 15:27:30 -03:00
arthurfiorette
c57916fd67
refactor: extracted static functions to a single file 2022-01-03 09:14:47 -03:00
arthurfiorette
6929b021e0
style: fixed prettier plugin order 2021-12-11 10:43:11 -03:00
arthurfiorette
b4ad24de48
refactor: made some methods static and public 2021-12-11 10:42:26 -03:00
arthurfiorette
07ec645a9d
perf: removed tslib and typed-core in favor of fast-defer 2021-12-08 16:46:15 -03:00
Arthur Fiorette
48e33c5d5a
feat: etag and if-modified-since support (#53)
* 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>
2021-11-15 10:43:20 -03:00
Arthur Fiorette
92b9ed7abf
feat: more headers supports, tests and must-revalidate fix (#51)
* feat: must-revalidate and headers enum
* test: added more tests
* test: test and code fixes
* test: more tests
2021-11-11 14:16:37 -03:00
Hazork
99906e57b9 deps: bump axios to v0.24 2021-10-28 11:40:15 -03:00