Skip to content

Commit cde9fda

Browse files
committed
chore: revert enabling on-demand on packages api
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
1 parent 24bb6c1 commit cde9fda

1 file changed

Lines changed: 1 addition & 31 deletions

File tree

backend/src/api/public/v1/packages/getPackage.ts

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { createHash } from 'crypto'
21
import type { Request, Response } from 'express'
32

43
import { NotFoundError } from '@crowd/common'
@@ -9,10 +8,8 @@ import {
98
getStewardshipSummary,
109
securityContactConfidenceBand,
1110
} from '@crowd/data-access-layer'
12-
import { WorkflowIdConflictPolicy, WorkflowIdReusePolicy } from '@crowd/temporal'
1311

1412
import { getPackagesQx } from '@/db/packagesDb'
15-
import { getPackagesTemporalClient } from '@/db/packagesTemporal'
1613
import { ok } from '@/utils/api'
1714
import { validateOrThrow } from '@/utils/validation'
1815

@@ -35,43 +32,16 @@ function repoMappingLabel(confidence: number | null): 'High' | 'Medium' | 'Low'
3532
return 'Low'
3633
}
3734

38-
// Deterministic per-purl id: concurrent requests for the same purl attach to the
39-
// same workflow run (WorkflowIdConflictPolicy.USE_EXISTING below) instead of each
40-
// kicking off its own ingest.
41-
function ondemandWorkflowId(purl: string): string {
42-
return `security-contacts-ondemand/${createHash('sha1').update(purl).digest('hex')}`
43-
}
44-
4535
export async function getPackage(req: Request, res: Response): Promise<void> {
4636
const { purl } = validateOrThrow(purlQuerySchema, req.query)
4737

4838
const qx = await getPackagesQx()
49-
let pkg = await getPackageDetailByPurl(qx, purl)
39+
const pkg = await getPackageDetailByPurl(qx, purl)
5040

5141
if (!pkg) {
5242
throw new NotFoundError()
5343
}
5444

55-
if (pkg.contactsLastRefreshed == null) {
56-
try {
57-
const packagesTemporal = await getPackagesTemporalClient()
58-
await packagesTemporal.workflow.execute('ingestSecurityContactsForPurlWorkflow', {
59-
taskQueue: 'packages-worker',
60-
workflowId: ondemandWorkflowId(purl),
61-
workflowIdReusePolicy: WorkflowIdReusePolicy.ALLOW_DUPLICATE,
62-
workflowIdConflictPolicy: WorkflowIdConflictPolicy.USE_EXISTING,
63-
// Bounds the request's wait if packages-worker is down or its task queue is
64-
// backed up — the activity's startToCloseTimeout only starts counting once a
65-
// worker picks the task up, so without this the request could hang indefinitely.
66-
workflowExecutionTimeout: '60 seconds',
67-
args: [purl],
68-
})
69-
pkg = (await getPackageDetailByPurl(qx, purl)) ?? pkg
70-
} catch (err) {
71-
req.log.warn(err, 'On-demand security contacts ingest failed — serving cached detail')
72-
}
73-
}
74-
7545
const [{ rows: advisories }, stewardshipSummary] = await Promise.all([
7646
getAdvisoriesByPackageId(qx, pkg.id),
7747
pkg.stewardshipId ? getStewardshipSummary(qx, Number(pkg.stewardshipId)) : null,

0 commit comments

Comments
 (0)