I am seeing this error in my nestjs application
(node:16561) UnhandledPromiseRejectionWarning: TypeError: this.contextUtils.getContextFactory is not a function at WsContextCreator.getMetadata (/Users/sajankumarvijayan/Documents/projects/review.io/node_modules/@nestjs/websockets/context/ws-context-creator.js:73:50) at WsContextCreator.create (/Users/sajankumarvijayan/Documents/projects/review.io/node_modules/@nestjs/websockets/context/ws-context-creator.js:28:68)
Here is my example code:
import {
SubscribeMessage,
WebSocketGateway,
WebSocketServer,
} from '@nestjs/websockets';
import { Server } from 'ws';
@WebSocketGateway()
export class SocketGateway {
@WebSocketServer()
server: Server;
@SubscribeMessage('event')
onEvent(client: any, data: any): void {
this.server.emit('update');
}
}
If i remove the @SubscribeMessage annotation the error is gone. I think this exception is not handled but looking for some answers and help to fix this. Thank you.
I faced the same issue and it disappeared after I upgraded @nestjs/core
and @nestjs/common
to 7.x.x
versions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With