-
-
Notifications
You must be signed in to change notification settings - Fork 798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: ee.on is not a function #1832
Comments
Same issue here |
Same issue happening for me as well, did anyone find a solution?? |
Hi @Stankman ! |
Hi, I'm facing a similar issue, I believe it is mostly similar to the issue of Stankman. It occurs when trying to access TypeError: ee.on is not a function
at first (C:\Workspaces\ws-nest\serverless-project\node_modules\ee-first\index.js:43:10)
at onSocket (C:\Workspaces\ws-nest\serverless-project\node_modules\on-finished\index.js:115:16)
at attachFinishedListener (C:\Workspaces\ws-nest\serverless-project\node_modules\on-finished\index.js:120:5)
at attachListener (C:\Workspaces\ws-nest\serverless-project\node_modules\on-finished\index.js:147:5)
at onFinished (C:\Workspaces\ws-nest\serverless-project\node_modules\on-finished\index.js:53:3)
at send (C:\Workspaces\ws-nest\serverless-project\node_modules\finalhandler\index.js:319:3)
at C:\Workspaces\ws-nest\serverless-project\node_modules\finalhandler\index.js:135:5
at C:\Workspaces\ws-nest\serverless-project\node_modules\express\lib\router\index.js:646:15
at next (C:\Workspaces\ws-nest\serverless-project\node_modules\express\lib\router\index.js:216:14)
at Function.handle (C:\Workspaces\ws-nest\serverless-project\node_modules\express\lib\router\index.js:175:3) |
Same Issue here. ✖ TypeError: ee.on is not a function |
yup same issue here :/ |
Guys I encountered the same issue. It seems the Lambda function doesn't work for the base route (/). To troubleshoot, try clearing the cache and create a test route, like /hello, then access it via http://localhost:3000/dev/hello. This worked for me, while accessing http://localhost:3000/dev still fails. I'm not certain of the exact cause, but this workaround might help! |
The way that I found to handle this problem was to parse the path before returning the server instance: if (event.path === '' || event.path === undefined) event.path = '/'; The entire code: import { NestFactory } from '@nestjs/core';
import serverlessExpress from '@vendia/serverless-express';
import { Callback, Context, Handler } from 'aws-lambda';
import { ReplaySubject, firstValueFrom } from 'rxjs';
import { FooModule } from './foo.module';
// Declare a ReplaySubject to store the serverlessExpress instance.
const serverSubject = new ReplaySubject<Handler>();
async function bootstrap(): Promise<Handler> {
console.log('COLD START: Initializing Nest');
const app = await NestFactory.create(FooModule);
await app.init();
const expressApp = app.getHttpAdapter().getInstance();
return serverlessExpress({ app: expressApp });
}
// Do not wait for lambdaHandler to be called before bootstraping Nest.
// Pass the result of bootstrap() into the ReplaySubject
bootstrap().then((server) => serverSubject.next(server));
type EventPayload = {
[key: string]: any;
};
export const handler: Handler = async (
event: EventPayload,
context: Context,
callback: Callback,
) => {
// Handle edge cases for root path
if (event.path === '' || event.path === undefined) event.path = '/';
// Convert the ReplaySubject to a Promise.
// Wait for bootstrap to finish, then start handling requests.
const server = await firstValueFrom(serverSubject);
return server(event, context, callback);
}; |
Bug Report
Current Behavior
When running
sls offline
for a Serverless application usingserverless-offline
with the configuration below, an error occurs:TypeError: ee.on is not a function
. This seems to prevent the expected startup of the local server.Sample Code
Expected behavior/code
The application should start without errors and expose the API endpoints locally using serverless-offline.
Environment
serverless
version: 4.4.7serverless-offline
version: 14.3.3node.js
version: v20.18.0OS
: macOS 15.0.1optional, if you are using any of the following frameworks to invoke handlers
nestJS
version: 10.4.5Possible Solution
It could be helpful to check for compatibility issues with serverless-offline or dependencies like ee-first in conjunction with the current node.js version.
Additional context/Screenshots
Output when running sls offline:
The text was updated successfully, but these errors were encountered: