Repository navigation
Fix duplicate plugin beforeQuery invocation and add registry regression tests (#71) - #367
Open
viralboterk wants to merge 1 commit into
Open
viralboterk wants to merge 1 commit into
viralboterk wants to merge 1 commit into
Conversation
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.
What was broken
StarbasePluginRegistry.beforeQuery()(src/plugin.ts) called each plugin'sbeforeQueryhook twice per query: once with the chainedsql/params(whose result was used), and a second time with the original, unchained
opts(whose result was discarded). Consequences:
(logging, counters, external calls, caching, etc.).
the previous plugin, so a plugin could observe a query that was never
actually executed.
query that an earlier plugin had already rewritten into an acceptable one.
The existing test only asserted
toHaveBeenCalled(), so the bug went unnoticed.What changes
src/plugin.ts: remove the strayawait plugin.beforeQuery(opts)call so eachhook runs exactly once, with the chained input.
src/plugin.test.ts: add meaningful regression tests for the registry'sbeforeQuerychain, as part of the Improve test coverage with Vitest #71 test coverage effort:(including a
-1param being rewritten), plus the untoucheddataSourceand
config;nullparam);No other production behavior changes.
How it is tested
pnpm test(Vitest) picks up the updatedsrc/plugin.test.ts. The new"exactly once" and "chained input" tests fail on the previous implementation
and pass with the fix.
Fixes #71
/claim #71
Note: this change was prepared with the help of an AI coding assistant. Happy to adjust anything you'd like.