on-finished icon indicating copy to clipboard operation
on-finished copied to clipboard

TypeError: ee.on is not a function

Open lmassaroli opened this issue 8 months ago • 3 comments

Guys I am having this issue sometimes when using Express, Lambda and HTTP API Gateway, do you know what can be the reason?

TypeError: ee.on is not a function
    at first (/var/task/node_modules/ee-first/index.js:43:10)
    at onSocket (/var/task/node_modules/on-finished/index.js:115:16)
    at attachFinishedListener (/var/task/node_modules/on-finished/index.js:120:5)
    at attachListener (/var/task/node_modules/on-finished/index.js:147:5)
    at onFinished (/var/task/node_modules/on-finished/index.js:53:3)
    at send (/var/task/node_modules/finalhandler/index.js:314:3)
    at /var/task/node_modules/finalhandler/index.js:133:5
    at /var/task/node_modules/express/lib/router/index.js:646:15
    at next (/var/task/node_modules/express/lib/router/index.js:265:14)
    at /var/task/node_modules/express/lib/router/index.js:646:15

This is my Lambda handler

import serverlessExpress from "@codegenie/serverless-express";
import { app } from "@src/app";

const serverlessExpressHandler = serverlessExpress({ app });

export const handler: any = async (
  event: Record<string, any>,
  context: any,
  callback: any
) => {
  /**
   * Handle edge cases for root path
   * https://github.com/dherault/serverless-offline/issues/1832
   */
  if (event.rawPath === "" || event.rawPath === undefined) event.rawPath = "/";

  return serverlessExpressHandler(event, context, callback);
};

lmassaroli avatar Apr 21 '25 02:04 lmassaroli

Hey @leoflood, I’m not entirely familiar with Lambdas, but could you give us more information, like which version of Node it uses, the version of Express, etc.?

bjohansebas avatar Apr 21 '25 02:04 bjohansebas

Hey @bjohansebas, sure! These are the versions in my package JSON.

{
  "engines": {
    "node": "20.10.0",
    "npm": "10.2.3"
  },
  "devDependencies": {
    "@types/bcrypt": "^5.0.2",
    "@types/cors": "^2.8.17",
    "@types/express": "^4.17.21",
    "@types/jest": "^29.5.12",
    "@types/jsonwebtoken": "^9.0.6",
    "@types/nodemailer": "^6.4.15",
    "@types/pako": "^2.0.3",
    "@types/pg": "^8.11.6",
    "@types/uuid": "^10.0.0",
    "jest": "^29.7.0",
    "nodemon": "^3.1.4",
    "ts-jest": "^29.1.5",
    "ts-node": "^10.9.2",
    "tsc-alias": "^1.8.10",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.5.4"
  },
  "dependencies": {
    "@codegenie/serverless-express": "^4.16.0",
    "@paypal/paypal-server-sdk": "^0.6.0",
    "@types/winston": "^2.4.4",
    "axios": "^1.7.7",
    "bcrypt": "^5.1.1",
    "cors": "^2.8.5",
    "dotenv": "^16.4.5",
    "express": "^4.19.2",
    "google-auth-library": "^9.14.2",
    "googleapis": "^146.0.0",
    "jsonwebtoken": "^9.0.2",
    "nodemailer": "^6.9.14",
    "pako": "^2.1.0",
    "pg": "^8.12.0",
    "uuid": "^10.0.0",
    "winston": "^3.13.0"
  }
}

lmassaroli avatar Apr 21 '25 03:04 lmassaroli

I am pretty sure this is not caused by the library here. It looks like the socket passed to onSocket is not the right thing, which I think it is different because it is not Node.js. Frankly, you are pretty behind on express and running a version we have issued CVE's for. I am not sure we can help here unless you can narrow it down more and also get things updated.

wesleytodd avatar Apr 23 '25 15:04 wesleytodd