Middy: The doNotWaitForEmptyEventLoop doesn't work on 10.x runtime

Created on 22 May 2019  路  7Comments  路  Source: middyjs/middy

This simple handler:

const middy = require('middy');
const { cors, doNotWaitForEmptyEventLoop } = require('middy/middlewares');

const check = async () => {
    return {
        statusCode: 200,
        body: JSON.stringify({
            success: true
        })
    }
};

module.exports.handler = middy(check)
    .use(cors())
    .use(doNotWaitForEmptyEventLoop());

Works fine on 8.10 runtime but with 10.x runtime function returns null and breaks API Gateway response.

When I remove the doNotWaitForEmptyEventLoop middleware works fine on 10.x.

I'm using version 0.27

bug

Most helpful comment

Is this still a thing?

I tested with the 1.0.0-beta.7 and it worked with the right response.

package.json

{
    "name": "middy-test",
    "devDependencies": {
        "serverless": "^1.66.0"
    },
    "dependencies": {
        "@middy/core": "^1.0.0-beta.7",
        "@middy/do-not-wait-for-empty-event-loop": "^1.0.0-beta.7"
    }
}

serverless.yml

---
service: middy-test

provider:
  name: aws
  runtime: nodejs10.x
  region: eu-central-1
  stage: test

functions:
  check:
    handler: index.handler

index.js

const middy = require('@middy/core');
const doNotWaitForEmptyEventLoop = require('@middy/do-not-wait-for-empty-event-loop');

const check = async () => {
    return {
        statusCode: 200,
        body: JSON.stringify({
            success: true
        })
    }
};

module.exports.handler = middy(check)
    .use(doNotWaitForEmptyEventLoop());

@lmammino Should we close this?

All 7 comments

Just wondering if there is any update on this? I know its part of v1.0.0 but it might be a long time before it's released.

Also have this problem

Same here..

@michalorman and others; Have you tried on v12.x (recently released), and/or the alpha branch (It's pretty stable, just lock in the version if you're worried about breaking changes)?

Is this still a thing?

I tested with the 1.0.0-beta.7 and it worked with the right response.

package.json

{
    "name": "middy-test",
    "devDependencies": {
        "serverless": "^1.66.0"
    },
    "dependencies": {
        "@middy/core": "^1.0.0-beta.7",
        "@middy/do-not-wait-for-empty-event-loop": "^1.0.0-beta.7"
    }
}

serverless.yml

---
service: middy-test

provider:
  name: aws
  runtime: nodejs10.x
  region: eu-central-1
  stage: test

functions:
  check:
    handler: index.handler

index.js

const middy = require('@middy/core');
const doNotWaitForEmptyEventLoop = require('@middy/do-not-wait-for-empty-event-loop');

const check = async () => {
    return {
        statusCode: 200,
        body: JSON.stringify({
            success: true
        })
    }
};

module.exports.handler = middy(check)
    .use(doNotWaitForEmptyEventLoop());

@lmammino Should we close this?

Closing for now, please comment if this is still an issue.

Thanks @abdala for reporting that this is fixed now and to @willfarrell for promptly closing the issue :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vladgolubev picture vladgolubev  路  4Comments

erikhagreis picture erikhagreis  路  4Comments

ChristianMurphy picture ChristianMurphy  路  4Comments

acdoussan picture acdoussan  路  3Comments

willfarrell picture willfarrell  路  8Comments