fix: resolve high-severity audit issues in core query and React bindings#3
Merged
ConsoleTVs merged 1 commit intomainfrom Apr 12, 2026
Merged
Conversation
- Fix fresh option falling back to constructor arg instead of instanceFresh - Fix fresh:true returning pending dedup promise instead of forcing new fetch - Fix next()/stream()/sequence() broken for plain object keys - Fix stale data displayed on key change in useQueryBasic - Fix shadowed generic <T> in useQueryActions.localMutate - Document React Compiler setup and rules in AGENTS.md - Add @babel/core as explicit devDependency (peer dep of @rolldown/plugin-babel) - Add test coverage for useQueryBasic, useQueryActions, and useQueryStatus hooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves all 6 high-severity issues identified during a deep code audit of the core query library and React bindings.
Core Library Fixes
H1:
freshoption ignoringconfigure()src/query/query.ts:345— Thefreshoption inquery()was falling back toinstanceOptions?.fresh(the original constructor argument) instead ofinstanceFresh(the runtime-mutable variable). This meant callingconfigure({ fresh: true })had no effect on subsequentquery()calls. Every other option correctly fell back to itsinstance*variable.H2:
fresh: truenot forcing a new fetch when request is in-flightsrc/query/query.ts:417-421— Whenfresh: truewas passed but a request was already in-flight,refetch()returned the existing pending promise from the resolver cache (deduplication). This defeated the entire purpose offresh. Fixed by aborting any existing in-flight request before callingrefetch().H3:
next()broken for plain object keyssrc/query/query.ts:504-511— The type signature ofnext()acceptedstring | { [K in keyof T]: string }(including plain objects), but the implementation only checkedArray.isArray(keys). A plain object like{ a: '/foo', b: '/bar' }was wrapped in[keys]and cast tostring[], producing completely wrong behavior. Fixed by handling all three cases:string,string[], and plain objects. Same fix applies tostream()andsequence()which delegate tonext().React Bindings Fixes
H4: Stale data on key change in
useQueryBasicsrc/react/hooks/useQueryBasic.ts:95—useState(use(promise))only captured the initial value. When thekeyprop changed to a different already-cached key,use()returned the new data butuseStateignored it (not initial render). The component displayed stale data from the previous key. Fixed by comparing theuse()-resolved value with current state and resetting when they differ.H5: Shadowed generic
<T>inuseQueryActions.localMutatesrc/react/hooks/useQueryActions.ts:93—localMutate<T = unknown>declared its own genericTthat shadowed the outer hook'sTfromuseQueryActions<T>. This disconnected the mutation function's type parameter from the hook's type, causing the returnedmutatefunction to default tounknowninstead of the caller's type. Fixed by removing the inner generic.Documentation & Dependencies
H6: React Compiler documentation + test coverage
AGENTS.mddocumenting build configuration, plugin order, and rules for React code (no manual memoization, immutability, etc.)@babel/coreas an explicit devDependency (required peer dep of@rolldown/plugin-babelper@vitejs/plugin-reactdocs)useQueryBasic,useQueryActions, anduseQueryStatushooks (previously 0 test coverage)Tests