CodeGenieApp / CodeGenieApp/serverless-express

Bug Report: ee.on is not a function Error with @codegenie/serverless-express 4.16.0

Đang mở
#698 8 bình luận 11 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
5.3k
Fork
676
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### __Environment:__

- __@codegenie/serverless-express:__ 4.16.0 (error occurs) / 4.15.0 (works)
- __Express:__ 4.19.2
- __Node.js:__ 20.x (AWS Lambda runtime)
- __TypeScript:__ 5.7.3

### __Error Description:__

When using @codegenie/serverless-express version 4.16.0, the following error occurs consistently in AWS Lambda:

```javascript
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 urlencodedParser (/var/task/node_modules/body-parser/lib/types/urlencoded.js:91:7)
```

### __Root Cause:__

The error appears to be introduced in version 4.16.0 of @codegenie/serverless-express. The `ee-first` library expects an EventEmitter-like object but receives something that doesn't have the `.on()` method, suggesting a regression in how response objects are handled in the Lambda environment.

### __Reproduction Steps:__

1. Create a Lambda function with @codegenie/serverless-express 4.16.0
2. Set up basic Express routes
3. Deploy to AWS Lambda
4. Make any HTTP request to the Lambda function

### __Workaround/Solution:__

Downgrade to the previous working version:

```json
{
"@codegenie/serverless-express": "^4.15.0"
}
```

### __Code Pattern That Triggers Error:__

```typescript
import express from 'express';
import serverlessExpress from '@codegenie/serverless-express';

const app = express();
app.get('/health', (req, res) => res.send('ok'));

// This pattern causes the error with version 4.16.0
const serverlessHandler = serverlessExpress({ app });

export const handler = async (event, context) => {
return serverlessHandler(event, context, () => {});
};
```

### __Expected Behavior:__

The serverless handler should process requests without throwing `ee.on is not a function` errors.

### __Actual Behavior:__

The error occurs during response processing, specifically when Express tries to attach event listeners for response completion tracking.

### __Additional Context:__

- The error only occurs in AWS Lambda environment, not in local development
- The error happens after successful initialization but during request processing
- Downgrading to 4.15.0 completely resolves the issue
- This suggests a regression introduced in version 4.16.0

### __Version Comparison:__

- __4.15.0:__ ✅ Works correctly
- __4.16.0:__ ❌ Throws `ee.on is not a function` error

### __Suggested Investigation:__

Please review changes made between versions 4.15.0 and 4.16.0, particularly around response object handling and event emitter interactions in the Lambda environment.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện lỗi với @codegenie/serverless-express 4.16.0 trên AWS Lambda bằng Express handler được cung cấp, sau đó so sánh cách xử lý response giữa 4.15.0 và 4.16.0. Báo cáo không nêu file nào trong repository hoặc test path nào, vì vậy hãy xác định entry point liên quan đến việc xử lý response và xác minh rằng các request hoàn tất mà không có lỗi ee.on, đồng thời giữ nguyên hành vi đang hoạt động của 4.15.0.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
aws, express, javascript, node.js
Lĩnh vực
api, backend, cloud
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.