fix api delayed jobs
This commit is contained in:
@@ -267,6 +267,10 @@ export async function postEvent(
|
|||||||
|
|
||||||
await withTiming('Promote previous job', prevEventJob.promote());
|
await withTiming('Promote previous job', prevEventJob.promote());
|
||||||
}
|
}
|
||||||
|
} else if (payload.name !== 'screen_view') {
|
||||||
|
contextLogger.send('no previous job', {
|
||||||
|
prevEventJob,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (createSessionStart) {
|
if (createSessionStart) {
|
||||||
|
|||||||
@@ -1,19 +1,22 @@
|
|||||||
|
import type { TransportTargetOptions } from 'pino';
|
||||||
import pino from 'pino';
|
import pino from 'pino';
|
||||||
|
|
||||||
const ENABLED = process.env.NODE_ENV === 'production';
|
const targets: TransportTargetOptions[] =
|
||||||
|
process.env.NODE_ENV === 'production'
|
||||||
const transport = pino.transport({
|
|
||||||
targets: ENABLED
|
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
target: '@logtail/pino',
|
target: '@logtail/pino',
|
||||||
options: { sourceToken: process.env.BETTERSTACK_TOKEN },
|
options: { sourceToken: process.env.BETTERSTACK_TOKEN },
|
||||||
},
|
},
|
||||||
|
]
|
||||||
|
: [
|
||||||
{
|
{
|
||||||
target: 'pino-pretty',
|
target: 'pino-pretty',
|
||||||
},
|
},
|
||||||
]
|
];
|
||||||
: [],
|
|
||||||
|
const transport = pino.transport({
|
||||||
|
targets,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const logger = pino(transport);
|
export const logger = pino(transport);
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
import type { Queue } from 'bullmq';
|
import type { Queue } from 'bullmq';
|
||||||
|
|
||||||
import { redis } from '../../redis';
|
|
||||||
|
|
||||||
export async function findJobByPrefix<T>(
|
export async function findJobByPrefix<T>(
|
||||||
queue: Queue<T, any, string>,
|
queue: Queue<T, any, string>,
|
||||||
matcher: string
|
matcher: string
|
||||||
) {
|
) {
|
||||||
const prefix = `bull:${queue.name}:`;
|
const delayed = await queue.getJobs('delayed');
|
||||||
const keys = await redis.keys(`${prefix}${matcher}*`);
|
return delayed.find((job) => job.opts.jobId?.startsWith(matcher));
|
||||||
const key = keys.findLast((key) => !key.endsWith(':logs'));
|
|
||||||
return key ? await queue.getJob(key.replace(prefix, '')) : undefined;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user