Skip to content

fix(plugin): skip non-function exports instead of throwing#35489

Open
ZachRouan wants to merge 1 commit into
anomalyco:devfrom
ZachRouan:fix/plugin-skip-non-function-exports
Open

fix(plugin): skip non-function exports instead of throwing#35489
ZachRouan wants to merge 1 commit into
anomalyco:devfrom
ZachRouan:fix/plugin-skip-non-function-exports

Conversation

@ZachRouan

Copy link
Copy Markdown

Issue for this PR

Closes #31575

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

getLegacyPlugins loops over every export of a plugin module and throws a TypeError on the first one that isn't a plugin function. That throw gets swallowed by the Effect.catch in 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 the seen-entry skip on the line right above. The export default { server } path is unaffected because it resolves through readV1Plugin before 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.ts that loads a plugin module with an extra export const VERSION beside the plugin function. It fails on dev (the hook never fires and trigger returns []) and passes with this change. The full plugin suite stays green (164 pass), and bun typecheck, Prettier, and oxlint are clean.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin silently fails to load when it exports a non-function value

1 participant