Git Product home page Git Product logo

Comments (4)

gojko avatar gojko commented on June 11, 2024

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.

legetz avatar legetz commented on June 11, 2024

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.

gojko avatar gojko commented on June 11, 2024

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:

const request = getRequest(event, context),
and could use packResult to return a "successful" result with code 400 instead of processing

from claudia-api-builder.

gojko avatar gojko commented on June 11, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.