question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

swagger-ui-bundle.js (~1MB) file too big for hosting in AWS Lambda behind ALB

See original GitHub issue

Q&A (please complete the following information)

  • OS: client Windows / server: Amazon Linux 2, AWS Lambda
  • Browser: all affected (it’s a server issue)
  • Version: N/A
  • Method of installation: via Swashbuckle.AspNetCore
  • Swagger-UI version: 3.25.0
  • Swagger/OpenAPI version: N/A

Describe the bug you’re encountering

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.:

  • is there a chance to decrease size of swagger-ui-bundle.js file?
  • could we split this file into smaller chunks?

Expected behavior

SwaggerUI can be hosted in AWS Lambda.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
DamianKedziorcommented, Jun 18, 2020

Hi @webron, just wanted to follow up with you and ask if you have a plan in mind to address this issue?

1reaction
srudenkordcommented, Mar 15, 2021

Just to confirm the workaround works. Code should be like the following

  public void ConfigureServices(IServiceCollection services)
        {

             ...

            services.AddResponseCompression(options =>
            {
                options.Providers.Add<BrotliCompressionProvider>();
                options.Providers.Add<GzipCompressionProvider>();
                options.MimeTypes = new[] {"application/json", "text/tab-separated-values", "application/javascript", "text/csv", "text"};
            });

            
        }
        
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            .....
            
            app.UseResponseCompression();

            .....   
        }        
Read more comments on GitHub >

github_iconTop Results From Across the Web

swagger-ui-bundle.js too large for AWS Lambda and ALB
Tracked this down to a AWS ALB error saying the response was too big. ALB targeting Lambda limits responses to 1MB. Confirmed the...
Read more >
Troubleshoot Application Load Balancer HTTP 502 errors - AWS
If the target is an AWS Lambda function, see Troubleshoot HTTP 502 errors when the target is a Lambda function in the Resolution...
Read more >
Upload Large Payloads - AWS Lambda and S3 - YouTube
Check My Udemy Courses ⭐️ AWS - The Complete Guide to Build Serverless REST APIs: https://bit.ly/3zr0EyV Learn to Deploy Containers on ......
Read more >
One thing is that ALB to Lambda restrictions ... - Hacker News
One thing is that ALB to Lambda restrictions suck. Lambdas have a 6mb response size. Api gateway has a 10mb response size. If...
Read more >
swagger-ui-bundle.js too large for AWS Lambda a...anycodings
swagger-ui-bundle.js too large for AWS Lambda and ALB Updated to .NET Core 3.1 and the latest anycodings_swagger ver ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found