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

Payload too large error(413) for request with request-body size >100KB in Express #209

Closed
PrathibaJee opened this issue Jul 25, 2022 · 7 comments · Fixed by #537 or #538
Closed

Payload too large error(413) for request with request-body size >100KB in Express #209

PrathibaJee opened this issue Jul 25, 2022 · 7 comments · Fixed by #537 or #538

Comments

@PrathibaJee
Copy link
Collaborator

PrathibaJee commented Jul 25, 2022

In the express framework , by default the request-body size is 100KB.
So, when the request-body exceeds 100KB , we are seeing the error,
"PayloadTooLargeError: request entity too large" with response code 413.

Proposal :
To fix this error , we have to tune the express app to use the customized express/urlencoded/limit and express/json/limit.

app.use(express.json({limit: <new limit>}));
app.use(express.urlencoded({limit: <new limit>}));

Note : Proposal needs to be modified as per the oas3-tools modelling.
Next steps :

  • Benchmark the maximum possible request-body as per our application requirement to propose value for the

  • If we are using NGINX , then need to observe whether NGINX allows the configured limit. If NGINX blocks this request , then need to include the following in the .conf file ,
    client_max_body_size 25M;

Additional details :
No change required in the OAS specification and loadfile.

@MartinSunal
Copy link
Collaborator

setting a limit requires changes in oas3-tools and it has been fixed in different distribution:
paxet-io/oas3-tools#2

Limit is set to 50mb.

The distribution with the fix has been released as version 2.3.1:
https://github.com/paxet-io/oas3-tools/releases/tag/v2.3.1
https://www.npmjs.com/package/@paxet/oas3-tools/v/2.3.1

Changes required in applications in order to use new distribution:
change package.json - replace "oas3-tools": "^2.2.3" with "@paxet/oas3-tools": "2.3.1"
change imports in *.js files (e.g. index.js) - replace require('oas3-tools') with require('@paxet/oas3-tools')

@PrathibaJee
Copy link
Collaborator Author

A new NPM package shall be created with the fix required to tune the requestBody size.

  1. Proposing to include the code changes into ApplicationPattern repository , in the server folder , creating a separate folder for Oas3-tools.
  2. Further we shall create and publish npm package from this source.

Kindly please let me know your views.Thanks.
Also we can discuss this in the SDN application development call on Dec 02 , 2022.

@PrathibaJee PrathibaJee added this to the AP v2.0.0_impl milestone Dec 1, 2022
@openBackhaul
Copy link
Owner

I understood that the original oas3-tools repository does not undergo any support any more.
So, I am fine with creating an /oas3-tools folder in the /server folder and creating an npm package from that.

@MartinSunal
Copy link
Collaborator

no problem, I will copy it to /server

@MartinSunal
Copy link
Collaborator

@IswaryaaS please publish npm package to npm registry after #537 is merged.

Changes required in applications in order to use new package after publish:
change package.json - replace "oas3-tools": "^2.2.3" with "openbackhaul-oas3-tools": "2.3.1"
change imports in *.js files (e.g. index.js) - replace require('oas3-tools') with require('openbackhaul-oas3-tools')

@IswaryaaS
Copy link
Collaborator

@MartinSunal , we published the package with updates in PR#537. After following the above steps and testing in Individual applications, got following error. Kindly have a check into this error occurred.

image

@IswaryaaS
Copy link
Collaborator

IswaryaaS commented Jan 25, 2023

@MartinSunal , the fix provided by you for this comment on issue works fine.
I published an npm package as version "2.3.1-alpha.1". (Note : It is about to be tested)

Steps followed to publish in windows environment:

  • npm install
  • npm run build
  • npm publish

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants