fix(plugin): skip non-function exports instead of throwing#35489
Open
ZachRouan wants to merge 1 commit into
Open
fix(plugin): skip non-function exports instead of throwing#35489ZachRouan wants to merge 1 commit into
ZachRouan wants to merge 1 commit into
Conversation
getLegacyPlugins threw a TypeError on the first non-function export, and that error is swallowed by the plugin apply catch, so a plugin module that exports anything besides its plugin function (a version constant, a helper) silently registered no hooks with no diagnostic. Skip non-plugin exports instead, matching the existing seen-entry skip right above it. Fixes anomalyco#31575
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.
Issue for this PR
Closes #31575
Type of change
What does this PR do?
getLegacyPluginsloops over every export of a plugin module and throws aTypeErroron the first one that isn't a plugin function. That throw gets swallowed by theEffect.catchin the plugin apply loop, so if a module exports anything alongside its plugin (a version constant, a helper), the whole plugin is dropped and no hooks register, with no error anywhere.This changes the throw to
continue, so non-plugin exports are skipped instead of discarding the module's real plugins. It matches theseen-entry skip on the line right above. Theexport default { server }path is unaffected because it resolves throughreadV1Pluginbefore this loop, so only the legacy named-export path was hitting the throw.How did you verify your code works?
Added a test in
test/plugin/trigger.test.tsthat loads a plugin module with an extraexport const VERSIONbeside the plugin function. It fails ondev(the hook never fires andtriggerreturns[]) and passes with this change. The full plugin suite stays green (164 pass), andbun typecheck, Prettier, and oxlint are clean.Screenshots / recordings
Not a UI change.
Checklist