After investigating hours I found the following issue:
My Setup:
- Angular CLI 6.0.1
- Angular Material 6.0.2
- Serverless (+serverless-webpack 5.1.5, +serverless-apigw-binary)
build steps:
- Build (Browser app) -> using the default CLI configuration
- Build the SSR server with Webpack
- Build the Lambda-Server and Bundle all sources into a serverless package
So far so good. Everything worked until I started using MatBottomSheet. When I injected this Service in my component nothing seems to be special.
Locally there was no problem, serving for development (worked). Create a production build and hosting it locally also worked.
The strange thing occurred when deploying it to lambda. The deployment seems to be ok. But when I called the lambda method via AWS Gateway -> to access the app. I got an internal server error.
In lambda logs i saw i got a timeout. (I tried to change the timeout period up to 10s, so setting a to short period was not the problem). Normally it took 70ms to render the whole site, but well.
It looks like there is an endless loop / deadlock or circular call etc.. whatever in material code, when packed with serverless for lambda.
Its took my some hours to find where the actual problem was. Bec. cloudwatch and all other AWS logs are rly. silent when u get a timeout. When i removed the MatBottomSheet from my app everything works again.
FYI.: I dont had to use MatBottomSheet directly. Injecting it in the component was enough. Importing the module without injecting the the service, also worked.
What I've already tried:
Normally my lambda server code uses expressjs, which is wrapped in aws-express ..
so I adapted the expressjs code -> just to return the static files, without rendering anything. -> The result didn't changed, i got a timeout.
next thing I tried: invoking the lambda method locally (with serverless) everything worked as expected.
I used the same Nodejs version (8.10) locally which is the same version as AWS Lambda uses. -> timeout error...
If anyone have an idea how to solve this problem, it would be really awesome.
My workaround: use lambda without SSR, or not using lambda...
thanks