We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
nitropack 2.10.4
https://stackblitz.com/edit/github-9uizvfes?file=server%2Froutes%2Findex.ts
Misbehaving code from the repro:
async function _foo() { return 'FOO'; } const foo = defineCachedFunction(_foo); async function _bar() { await new Promise((resolve) => setTimeout(resolve, 1)); return 'BAR'; } const bar = defineCachedFunction(_bar); async function main() { // Expected: FOO BAR // Actual result: FOO FOO console.log(await foo()); await new Promise((resolve) => setTimeout(resolve, 100)); console.log(await bar()); } main();
defineCachedFunction is supposed to guess cache key from the function name, and only use _ as a fall back:
defineCachedFunction
_
Guessed from function name if not provided, and falls back to '_' otherwise.
However, name is never taken from the function, _ is always used. This is due to bug where the default is taken before looking up function name:
nitro/src/runtime/internal/cache.ts
Lines 40 to 46 in 005a74f
As you can see opts.name is taken first, which comes from defaultCacheOptions(), which always returns { name: "_" }.
opts.name
defaultCacheOptions()
{ name: "_" }
Lines 25 to 32 in 005a74f
No response
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Environment
nitropack 2.10.4
Reproduction
https://stackblitz.com/edit/github-9uizvfes?file=server%2Froutes%2Findex.ts
Misbehaving code from the repro:
Describe the bug
defineCachedFunction
is supposed to guess cache key from the function name, and only use_
as a fall back:However, name is never taken from the function,
_
is always used. This is due to bug where the default is taken before looking up function name:nitro/src/runtime/internal/cache.ts
Lines 40 to 46 in 005a74f
As you can see
opts.name
is taken first, which comes fromdefaultCacheOptions()
, which always returns{ name: "_" }
.nitro/src/runtime/internal/cache.ts
Lines 25 to 32 in 005a74f
Additional context
No response
Logs
The text was updated successfully, but these errors were encountered: