dougmoscrop / serverless-http

Use your existing middleware framework (e.g. Express, Koa) in AWS Lambda 🎉
Other
1.72k stars 165 forks source link

TypeError: Cannot set property 'corked' of undefined #158

Closed adamnoakes closed 4 years ago

adamnoakes commented 4 years ago

100% reproducible for me in v2.4.0. 2.3.2 is fine.

I'm using koa:

import serverless from 'serverless-http';
import Koa from 'koa';

const app = new Koa();

app.use(ctx => {
  ctx.body = 'Hello World';
});
module.exports.handler = serverless(app);

results in internal server error on AWS Lambda. Logs from lambda:


START RequestId: 6cd82d09-b15f-4220-b510-bdd58c9a9334 Version: $LATEST
15:20:33
2020-05-11T15:20:33.424Z 6cd82d09-b15f-4220-b510-bdd58c9a9334 ERROR undefined
15:20:33
2020-05-11T15:20:33.424Z 6cd82d09-b15f-4220-b510-bdd58c9a9334 ERROR TypeError: Cannot set property 'corked' of undefined at ServerlessResponse.end (_http_outgoing.js:780:39) at respond (/var/task/node_modules/koa/lib/application.js:255:43) at handleResponse (/var/task/node_modules/koa/lib/application.js:164:34)
15:20:33
2020-05-11T15:20:33.424Z 6cd82d09-b15f-4220-b510-bdd58c9a9334 ERROR undefined
15:20:33
END RequestId: 6cd82d09-b15f-4220-b510-bdd58c9a9334```
dougmoscrop commented 4 years ago

What version of Node?

dougmoscrop commented 4 years ago

oh, and version of Koa

dougmoscrop commented 4 years ago

Try 2.4.1, but I'd still like to know what version(s) as I wrote a test and could not reproduce it, probably because of what version of Koa I was using

adamnoakes commented 4 years ago

Node.js 12, i never tried 10. Koa version is 2.11

adamnoakes commented 4 years ago

Try 2.4.1, but I'd still like to know what version(s) as I wrote a test and could not reproduce it, probably because of what version of Koa I was using

2.4.1 appears to be working 👍

dougmoscrop commented 4 years ago

okay great, sorry about that!

adamnoakes commented 4 years ago

No problem, thanks for patching so quickly.