You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At $WORK we have a fairly complicated Dancer2 app that's grown over the years. It's composed of three different Dancer2 apps, one handling web requests, another handling API requests, and another for a weird edge case that isn't worth getting into. On development, our psgi file looks something like
builder {
mount '/'=> App::Web->to_app;
mount '/api'=> App::API->to_app;
mount '/other'=> App::Other->to_app;
};
Cool. We have some Dancer2::Plugin cases to share code between them. It's been working pretty well so far.
For a new ticket, we're adding a new endpoint in App::API that uses a plugin, and this plugin -- which worked fine before -- spits out errors like this:
Can't call method \"var\" on an undefined value at lib/App/Plugin/StaticPage.pm line 273.\n
OK. I dug into it. Eventually I figured out that for that bit of code, $plugin->app and $plugin->dsl->app referred to the different apps. I need to render a template in the API with $plugin->dsl->template. Calling that invokes the hooks for the web app, and from there everything blows up. It looks like whichever app loads the plugin first stakes its claim on the dsl() function installed by Dancer2::Plugin:
Hello!
At $WORK we have a fairly complicated Dancer2 app that's grown over the years. It's composed of three different Dancer2 apps, one handling web requests, another handling API requests, and another for a weird edge case that isn't worth getting into. On development, our psgi file looks something like
Cool. We have some Dancer2::Plugin cases to share code between them. It's been working pretty well so far.
For a new ticket, we're adding a new endpoint in App::API that uses a plugin, and this plugin -- which worked fine before -- spits out errors like this:
And the line is
OK. I dug into it. Eventually I figured out that for that bit of code,
$plugin->app
and$plugin->dsl->app
referred to the different apps. I need to render a template in the API with$plugin->dsl->template
. Calling that invokes the hooks for the web app, and from there everything blows up. It looks like whichever app loads the plugin first stakes its claim on thedsl()
function installed by Dancer2::Plugin:Dancer2/lib/Dancer2/Plugin.pm
Lines 474 to 483 in 92ed2f6
In short: I think multiple instances of the same plugin share the same dsl object. This causes weird conflicts between the apps.
I'll see if I can put together a merge request reproducing this behaviour.
The text was updated successfully, but these errors were encountered: