Skip to content

Commit

Permalink
fix issues after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
davwas committed Jan 15, 2024
1 parent f5986e4 commit 060d31b
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion apps/server/src/modules/tldraw/controller/tldraw.ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ export class TldrawWs implements OnGatewayInit, OnGatewayConnection {

private closeClientAndLogError(client: WebSocket, code: WsCloseCodeEnum, data: string, err: Error): void {
client.close(code, data);
this.logger.warning(new WebsocketCloseErrorLoggable(err, `(${code}) ${data}`));
this.logger.warning(new WebsocketCloseErrorLoggable(`(${code}) ${data}`, err));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ describe('tldraw entity', () => {

expect(tldraw).toBeInstanceOf(TldrawDrawing);
});

it('should throw with empty docName', () => {
const call = () => tldrawEntityFactory.build({ docName: '' });

expect(call).toThrow();
});
});
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Entity, Index, Property } from '@mikro-orm/core';
import { BadRequestException } from '@nestjs/common';
import { BaseEntity } from '@shared/domain/entity';
import { BaseEntity } from '@shared/domain/entity/base.entity';

export interface TldrawDrawingProps {
_id?: string;
Expand Down Expand Up @@ -35,7 +34,6 @@ export class TldrawDrawing extends BaseEntity {

constructor(props: TldrawDrawingProps) {
super();
if (!props.docName) throw new BadRequestException('Tldraw element should have name.');
this.docName = props.docName;
this.version = props.version;
this.value = props.value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('WebsocketCloseErrorLoggable', () => {
const error = new Error('test');
const errorMessage = 'message';

const loggable = new WebsocketCloseErrorLoggable(error, errorMessage);
const loggable = new WebsocketCloseErrorLoggable(errorMessage, error);
return { loggable, error, errorMessage };
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ErrorLogMessage, Loggable, LogMessage, ValidationErrorLogMessage } from '@src/core/logger';

export class WebsocketCloseErrorLoggable implements Loggable {
constructor(private readonly error: Error, private readonly message: string) {}
constructor(private readonly message: string, private readonly error: Error) {}

getLogMessage(): LogMessage | ErrorLogMessage | ValidationErrorLogMessage {
return {
Expand Down
4 changes: 3 additions & 1 deletion apps/server/src/modules/tldraw/service/tldraw.ws.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export class TldrawWsService {
try {
ws.close();
} catch (err) {
this.logger.warning(new WebsocketCloseErrorLoggable(err as Error));
this.logger.warning(
new WebsocketCloseErrorLoggable('Error while closing websocket, it may already be closed', err as Error)
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/tldraw/tldraw.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Dictionary, IPrimaryKey } from '@mikro-orm/core';
import { AuthorizationModule } from '@modules/authorization';
import { config } from './config';
import { TldrawDrawing } from './entities';
import { TldrawController } from './controller/tldraw.controller';
import { TldrawController } from './controller';
import { TldrawService } from './service';
import { TldrawBoardRepo, TldrawRepo, YMongodb } from './repo';

Expand Down

0 comments on commit 060d31b

Please sign in to comment.