Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Function browsershot not found in environment staging but fine locally #136

Open
jimhill opened this issue Nov 15, 2023 · 2 comments

Comments

@jimhill
Copy link

jimhill commented Nov 15, 2023

Problem

The issue occurs for me using wnx/sidecar-browsershot (which I know isn't this package), but having run through as much of the code as I can, it feels like this is a Sidecar thing.

Everything runs perfectly well in my local environment, however as soon as I run from our AWS staging environment I get the following error when trying to call it:

staging.ERROR: Function `browsershot` not found in environment `staging`.
It may exist other environments, you may need to overwrite the environment while deploying to `staging`.
See https://hammerstone.dev/sidecar/docs/main/functions/deploying#faking-the-environment for more information. {"userId":1,"exception":"[object] (Hammerstone\\Sidecar\\Exceptions\\FunctionNotFoundException(code: 0): Function `browsershot` not found in environment `staging`.
It may exist other environments, you may need to overwrite the environment while deploying to `staging`.
See https://hammerstone.dev/sidecar/docs/main/functions/deploying#faking-the-environment for more information. at /var/app/current/vendor/hammerstone/sidecar/src/Exceptions/FunctionNotFoundException.php:23)
[stacktrace]
#0 /var/app/current/vendor/hammerstone/sidecar/src/Manager.php(108): Hammerstone\\Sidecar\\Exceptions\\FunctionNotFoundException::make(Object(Wnx\\SidecarBrowsershot\\Functions\\BrowsershotFunction))
#1 /var/app/current/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(337): Hammerstone\\Sidecar\\Manager->execute(Object(Wnx\\SidecarBrowsershot\\Functions\\BrowsershotFunction), Array, false, 'RequestResponse')
...

The lambdas are there with the correct names, they have the exact same code in too.

Any thoughts or any more I can do to help diagnose the issue?

Related issue:

stefanzweifel/sidecar-browsershot#89

@jimhill jimhill changed the title No Getting Function browsershot not found in environment staging but fine locally Nov 15, 2023
@jimhill
Copy link
Author

jimhill commented Nov 16, 2023

So I have managed to isolate the problem, and work around it. Just haven't dug in enough to understand why it's a problem and to see if it's a config issue in our staging environment.

The issue is in the nameWithPrefix() method in Hammerstone\Sidecar\LambdaFunction.

https://github.com/hammerstonedev/sidecar/blob/5d1e03bd023962287aab61870a152f9d150c83c0/src/LambdaFunction.php#L120C37-L121C6

Our APP_NAME env var is set to something like AppName Staging.

Using artisan sidecar:deploy --activate , the deployed lambda then has a name like sc-appname-staging-browsershot.

But when executed, the $prefix-$name value looks in the method is sc-appname-staging-staging-browsershot


💡 Currently the workaround for now has been to set an env var for SIDECAR_APP_NAME to just AppName.

@hayden-ellis
Copy link

Thank you for this!!

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

No branches or pull requests

2 participants