Comments (4)
no, that breaks backwards compatibility. sending application/json with invalid json should throw an error. If you need to send invalid JSON, then use text/plain or something else as the content type.
from claudia-api-builder.
I understand that but it will crash the whole Lambda and returns 502 error:
2017-03-16T11:59:20.556Z f97a5269-0a3f-11e7-b93a-6d9d98ea6f88 SyntaxError: Unexpected end of input
at Object.parse (native)
at convertApiGWProxyRequest (/var/task/node_modules/claudia-api-builder/src/convert-api-gw-proxy-request.js:80:22)
at ApiBuilder.getRequest (/var/task/node_modules/claudia-api-builder/src/api-builder.js:233:12)
at ApiBuilder.self.proxyRouter (/var/task/node_modules/claudia-api-builder/src/api-builder.js:322:19)
2017-03-16T11:59:20.637Z END RequestId: f97a5269-0a3f-11e7-b93a-6d9d98ea6f88
2017-03-16T11:59:20.637Z REPORT RequestId: f97a5269-0a3f-11e7-b93a-6d9d98ea6f88 Duration: 6335.45 ms Billed Duration: 6400 ms Memory Size: 128 MB Max Memory Used: 23 MB
2017-03-16T11:59:20.637Z RequestId: f97a5269-0a3f-11e7-b93a-6d9d98ea6f88 Process exited before completing request
Next API call will take around 10 seconds to complete since AWS needs to start another thread/instance to fullfill the valid request.
from claudia-api-builder.
10 secs to start a new lambda is likely a problem with your aws account, and you should speak to your aws account manager about that. launching a new lambda with node.js should take < 1s.
having said that, if you want to submit a PR that responds with 400 bad request in case of a json parse error, that would be useful and I'll merge it. The change should probably go somewhere here:
claudia-api-builder/src/api-builder.js
Line 322 in 7f4ab2e
packResult
to return a "successful" result with code 400 instead of processingfrom claudia-api-builder.
2.4.2 now on NPM handles such errors more gracefully, so it won't crash but report a 500 invalid request
from claudia-api-builder.
Related Issues (20)
- One API Gateway for different lambda. HOT 1
- Premature Exit while using Async.js with no results HOT 2
- Log path to CloudWatch HOT 5
- Add 'Access-Control-Allow-Origin' header to Authorizer's error responses HOT 2
- Question: Does it build to new AWS node 8.10.0 runtime? HOT 1
- Handling dynamic path variables when running locally HOT 1
- [Improvement] Use Method-Aware Status Codes HOT 1
- Type defintions for IDEs HOT 1
- ApiBuilder.ApiResponse is not a constructor error @ claudia-api-builder v3.0.x HOT 1
- Unable to use ApiResponse to return readable errors when serving binary content HOT 3
- CORS with Cognito Authorizer HOT 2
- Environment variable aka stage dev/prod HOT 1
- Add options to `ApiResponse` HOT 1
- A sibling ({uuid}) of this resource already has a variable path part -- only one is allowed HOT 1
- Wrong document in cors.md HOT 1
- Authorization with Cognito User Pools and Axios client-side HOT 1
- Default CORs settings (allow-origin: * & allow-credentials: true) Breaks Ajax
- Lambda Node 12 support
- Throwing classes derived from ApiBuilder.ApiResponse is not working correctly
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from claudia-api-builder.