-
Notifications
You must be signed in to change notification settings - Fork 567
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
Cache interceptor failing with "invalid onError method" #3973
Comments
This is somehow expected; the dispatcher returned by If changed from setGlobalDispatcher(getGlobalDispatcher().compose(interceptors.cache())) to setGlobalDispatcher(new Agent().compose(interceptors.cache())) The issue is gone; it seems we sadly broke the contract here without noticing. |
@metcoder95 the two behaviors should ideally be identitical in the given snippet, so something very odd is at play. My theory is that somehow undic / fetch gets loaded in Node.js core before the one on the first line. Anyhow, we should be able to handle this. @ronag wdyt? Should we bump the global undici version and deal with this somewhat? |
Sure but I'm not sure how we deal with it? Should we just revert the API changes and find a less breaking variation? |
Yeah, that's the same thing I noticed; that's why I assumed it was "somehow" expected as the FWIW v22 and v23 uses Undici |
I don't think we should revert. My take is that if getGlobalDispatcher() is called and there is a v6 dispatcher there, it gets autowrapped.
This should not happen, it should be lazily loaded. |
Bug Description
I'm trying to make use of Undici 7's new caching feature but I'm getting this error when trying to follow the example provided in the announcement blog post: https://blog.platformatic.dev/undici-v7-is-here#heading-caching
Reproducible By
I'm using Node.js v23.4.0 (and also tried v23.5.0 with the same result) on macOS Sonoma 14.5. I've tried undici version 7.2.0, 7.1.1, 7.1.0 and 7.0.0.
Expected Behavior
No error to be thrown and the same response body to be printed for both requests.
Additional context
I also tried this example using the SqliteCacheStore but get the same error message. Although it did create a "cache.db" file.
The text was updated successfully, but these errors were encountered: