T-16: M0.1b — Make repo-wide bun test green: fix queue, shutdown-signal and research-workflow test failures

This commit is contained in:
Studio 2026-11-27 12:01:06 -05:00
parent 890761e0d5
commit 9c4e87cdfd
17 changed files with 366 additions and 266 deletions

View file

@ -99,6 +99,14 @@ export class QueueManager {
this.ioredisConnection = deps?.createRedis
? deps.createRedis(ioredisOptions)
: new Redis(ioredisOptions);
if (typeof this.ioredisConnection.on === 'function') {
this.ioredisConnection.on('error', error => {
this.logger.error('QueueManager Redis connection error', {
service: this.serviceName,
error,
});
});
}
// Rate limiter will be initialized when rules are added dynamically
// No longer initialized from config

View file

@ -123,7 +123,7 @@ export class Queue {
// Initialize queue events if workers will be used
if (config.workers && config.workers > 0) {
this.queueEvents = new QueueEvents(queueName, { connection });
this.queueEvents = this.createQueueEvents(connection);
}
// Start workers if requested and not explicitly disabled
@ -262,12 +262,18 @@ export class Queue {
return await this.bullQueue.getJob(jobId);
}
private createQueueEvents(connection: ReturnType<typeof getRedisConnection>): QueueEvents {
const queueEvents = new QueueEvents(this.queueName, { connection });
queueEvents.on('error', error =>
this.logger.error('QueueEvents connection error', { queueName: this.queueName, error })
);
return queueEvents;
}
/** Wait for a result using a QueueEvents connection owned by this queue. */
async waitForJob<T>(job: Job<unknown, T>, timeout = 30000): Promise<T> {
if (!this.queueEvents) {
this.queueEvents = new QueueEvents(this.queueName, {
connection: getRedisConnection(this.redisConfig),
});
this.queueEvents = this.createQueueEvents(getRedisConnection(this.redisConfig));
}
await this.queueEvents.waitUntilReady();
return job.waitUntilFinished(this.queueEvents, timeout);
@ -589,7 +595,7 @@ export class Queue {
// Initialize queue events if not already done
if (!this.queueEvents) {
const connection = getRedisConnection(this.redisConfig);
this.queueEvents = new QueueEvents(this.queueName, { connection });
this.queueEvents = this.createQueueEvents(connection);
}
this.startWorkers(workerCount, concurrency);