Skip to content

Plugin loader: activate() failure wrap drops err.code — FST_ERR_DUPLICATED_ROUTE only identifiable by string-matching #599

Description

@melvincarvalho

What happens

When a plugin's activate() throws — e.g. a route collision with another plugin — the loader re-wraps the error as:

plugin <id>: activate() failed: Method 'GET' already declared for route '/.well-known/webfinger'

The original error's code (FST_ERR_DUPLICATED_ROUTE) is stripped in the wrap, so callers and tests can only string-match the message to distinguish a route collision from any other activation failure.

Evidence

Witnessed while deliberately colliding two plugins on /.well-known/webfinger (webfinger + remotestorage): https://github.com/JavaScriptSolidServer/plugins/tree/gh-pages/remotestorage (README, Findings — the collision test asserts on the message because the code is gone). Also REPORT.md there, bug #4.

Suggested fix

Preserve the original error when re-wrapping: copy code onto the wrapper, or use new Error(msg, { cause: err }) so both the code and the stack survive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpluginCould be implemented as a plugin (#206); core/plugin line defined in #564

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions