This issue is related to size of the swagger-ui-bundle.js file. Currently it's close to 1MB which makes it not possible to host in AWS Lambda (behind AWS ALB - Application Load Balancer).
AWS ALB + AWS Lambda has a limit for files it can transfer which is set to 1MB which has been already reached when trying to serve swagger-ui-bundle.js file from version 3.25.0
This issue is to open the discussion about how we could potentially solve it, e.g.:
swagger-ui-bundle.js file?SwaggerUI can be hosted in AWS Lambda.
@DamianKedzior what size _would_ work?
@webron I am pretty sure current size of 974KB just passed the treshold. I used some older version where file size was around 956KB it was working fine.
So if there is a chance to add some additional minification or remove some not needed code it could make it work again.
Thanks @DamianKedzior. Our general size check is for the bundle to be < 1MB (as part of our CI). However, it's been long enough since we last did a manual size audit, so it's probably time to do one again.
Hi @webron,
just wanted to follow up with you and ask if you have a plan in mind to address this issue?
Workaround - enable gzip response compression for mime type application/javascript. This will compress the bundle js file within .net core, thus greatly reducing the size and getting under the 1mb lambda limit. We do this also for json and other mime types in order to be able to provide much larger responses to our api clients than we could without it. They are required to specify the accept-encoding gzip, deflact request header.
Chrome and I assume other modern browsers will automatically specify the accept-encoding header when retrieving content. You can see in the response headers that the bundler js comes back as gzip and reduced to around 350kb.
services.AddResponseCompression(options =>
{
options.Providers.Add<GzipCompressionProvider>();
options.EnableForHttps = true;
options.MimeTypes = new[]
{
"application/json",
"text/tab-separated-values",
"application/javascript",
"text/csv",
"text"
};
}
);
@DamianKedzior I think @ronl has a good answer, and probably the most reliable long term answer. That said, there has been effort to reduce the bundle size as well as offer an es2015 bundle. The most recent release of [email protected] is ~960KB
Actually we did the same thing @ronl suggested some time ago and I forgot to post the workaround here :)
Added the startup code from @ronl but its not gzipping the file. Anything else others had to do?
Added the startup code from @ronl but its not gzipping the file. Anything else others had to do?
What browser are you using? If you watch in the developer tools, is it sending the request header "accept-encoding" with gzip and deflate?
yes
@rschiefer , on the IAppLIcationBuilder app, try ...
app.UseResponseCompression()
to enable
Most helpful comment
Hi @webron,
just wanted to follow up with you and ask if you have a plan in mind to address this issue?