Skip to content

Commit 74cb84d

Browse files
committed
fix(push): remove ScheduleModule, use manual setInterval for retry polling
- Replaced @interval decorator with manual setInterval in onAppBootstrap to avoid ScheduleModule reflect-metadata TypeError during Swagger generation (CI contract-check crash) - Removed ScheduleModule import from PushModule - Store pollTimer reference for cleanup in onAppClose Ref: #378
1 parent c6e99d0 commit 74cb84d

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/package/push/push-retry.service.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Injectable, SCOPE } from '@danet/core';
2-
import { Interval } from '@danet/core';
32
import { OnAppBootstrap, OnAppClose } from '@danet/core/hook';
43
import { createLazyClient, type Redis } from '@db/redis';
54
import { SecretService } from '@scope/secret';
@@ -28,6 +27,7 @@ const REDIS_KEY = 'edge:push:retry';
2827
export class PushRetryService implements OnAppBootstrap, OnAppClose {
2928
private redis!: Redis;
3029
private polling = false;
30+
private pollTimer: ReturnType<typeof setInterval> | undefined;
3131

3232
constructor(
3333
secret: SecretService,
@@ -73,7 +73,6 @@ export class PushRetryService implements OnAppBootstrap, OnAppClose {
7373
}
7474

7575
/** Poll for due retry jobs and attempt delivery. Runs every minute. */
76-
@Interval(RETRY_POLL_INTERVAL_MS)
7776
async poll(): Promise<void> {
7877
if (this.polling || !this.redis.isConnected) return;
7978
this.polling = true;
@@ -139,6 +138,12 @@ export class PushRetryService implements OnAppBootstrap, OnAppClose {
139138
this.logger.instance.debug(
140139
`Push-retry Redis connection validated: ${pong}`,
141140
);
141+
// Start polling interval (manual setInterval avoids
142+
// ScheduleModule + @Interval crash during Swagger generation)
143+
this.pollTimer = setInterval(
144+
() => this.poll().catch(() => {}),
145+
RETRY_POLL_INTERVAL_MS,
146+
);
142147
} catch (err) {
143148
this.logger.instance.warn(
144149
'Push-retry Redis connection failed during bootstrap. Push retries will be unavailable until Redis is configured.',
@@ -148,6 +153,9 @@ export class PushRetryService implements OnAppBootstrap, OnAppClose {
148153
}
149154

150155
async onAppClose(): Promise<void> {
156+
if (this.pollTimer !== undefined) {
157+
clearInterval(this.pollTimer);
158+
}
151159
if (this.redis.isConnected) {
152160
this.redis.close();
153161
}

src/package/push/push.module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Module, ScheduleModule } from '@danet/core';
1+
import { Module } from '@danet/core';
22
import { LoggerModule } from '@scope/logger';
33
import { DatabaseModule } from '@scope/database';
44
import { ExperimentModule } from '@scope/experiment';
@@ -17,7 +17,6 @@ import { PushRetryService } from './push-retry.service.ts';
1717
ExperimentModule,
1818
RateLimitModule,
1919
PushSenderModule,
20-
ScheduleModule,
2120
],
2221
controllers: [PushController],
2322
injectables: [

0 commit comments

Comments
 (0)