Skip to content

Commit d3ccbb3

Browse files
committed
Fix some cyclic dependencies
These were chaos. NodeJS just exited, no error or logs. This crash happened in `Injector.loadInstance` on the returning the `instanceHost.donePromise`. I believe the cycle check right above it should have caught this, but it didn't. I'm clueless on how node just exited too... somehow a deadlock or empty event loop somehow?
1 parent e87927b commit d3ccbb3

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/components/file/file.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
GetObjectCommand as GetObject,
33
PutObjectCommand as PutObject,
44
} from '@aws-sdk/client-s3';
5-
import { Injectable } from '@nestjs/common';
5+
import { forwardRef, Inject, Injectable } from '@nestjs/common';
66
import { bufferFromStream, cleanJoin, type Nil } from '@seedcompany/common';
77
import { fileTypeFromBuffer } from 'file-type';
88
import { intersection } from 'lodash';
@@ -60,6 +60,7 @@ export class FileService {
6060
private readonly repo: FileRepository,
6161
private readonly rollbacks: RollbackManager,
6262
private readonly config: ConfigService,
63+
@Inject(forwardRef(() => MediaService))
6364
private readonly mediaService: MediaService,
6465
private readonly eventBus: IEventBus,
6566
@Logger('file:service') private readonly logger: ILogger,

src/core/authentication/identity.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Inject, Injectable } from '@nestjs/common';
1+
import { forwardRef, Inject, Injectable } from '@nestjs/common';
22
import type { ID, Role } from '~/common';
33
import { type AuthenticationService } from '../../components/authentication';
44
import { SessionHost } from '../../components/authentication/session.host';
@@ -9,7 +9,7 @@ import { SessionHost } from '../../components/authentication/session.host';
99
@Injectable()
1010
export class Identity {
1111
constructor(
12-
@Inject('AUTHENTICATION')
12+
@Inject(forwardRef(() => 'AUTHENTICATION'))
1313
private readonly auth: AuthenticationService & {},
1414
private readonly sessionHost: SessionHost,
1515
) {}

src/core/database/database.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable } from '@nestjs/common';
1+
import { forwardRef, Inject, Injectable } from '@nestjs/common';
22
import { entries, mapKeys } from '@seedcompany/common';
33
import { Connection, node, type Query, relation } from 'cypher-query-builder';
44
import { LazyGetter } from 'lazy-get-decorator';
@@ -64,6 +64,7 @@ export class DatabaseService {
6464
constructor(
6565
private readonly db: Connection,
6666
private readonly config: ConfigService,
67+
@Inject(forwardRef(() => Identity))
6768
private readonly identity: Identity,
6869
private readonly shutdown$: ShutdownHook,
6970
@Logger('database:service') private readonly logger: ILogger,

0 commit comments

Comments
 (0)