Skip to content

Commit fe7028d

Browse files
committed
Merge branch 'main' of github.com:payloadcms/payload into fix/mime-validation-tempfiles
2 parents 4838c05 + 289e2b6 commit fe7028d

11 files changed

Lines changed: 72 additions & 39 deletions

File tree

docs/configuration/globals.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ It's often best practice to write your Globals in separate files and then import
3636
Here is what a simple Global Config might look like:
3737

3838
```ts
39-
import { GlobalConfig } from 'payload'
39+
import type { GlobalConfig } from 'payload'
4040

4141
export const Nav: GlobalConfig = {
4242
slug: 'nav',
@@ -107,7 +107,7 @@ The behavior of Globals within the [Admin Panel](../admin/overview) can be fully
107107
To configure Admin Options for Globals, use the `admin` property in your Global Config:
108108

109109
```ts
110-
import { GlobalConfig } from 'payload'
110+
import type { GlobalConfig } from 'payload'
111111

112112
export const MyGlobal: GlobalConfig = {
113113
// ...

examples/remix/website/Dockerfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
FROM node:22.14.0-alpine AS base
2+
3+
FROM base AS builder
4+
RUN apk add --no-cache libc6-compat
5+
WORKDIR /app
6+
7+
RUN npm install -g pnpm@latest-10
8+
9+
COPY . .
10+
11+
RUN apk update \
12+
apk add --no-cache libc6-compat
13+
14+
WORKDIR /app
15+
16+
ENV NODE_ENV=production
17+
RUN pnpm install --no-frozen-lockfile
18+
RUN pnpm --filter website build
19+
20+
FROM base AS runner
21+
22+
RUN npm install -g @remix-run/serve@latest
23+
WORKDIR /app
24+
COPY --from=builder /app/website/build/ ./build
25+
26+
# We need to install sharp again to avoid copying node_modules into the final image.
27+
# Sharp can't be bundled into the server file since it will throw an
28+
# __dirname is not defined error
29+
RUN npm install sharp@0.32.6
30+
31+
# These files are required by Payload to avoid file opening errors
32+
# https://github.com/payloadcms/payload/issues/11276
33+
COPY --from=builder /app/website/package.json ./package.json
34+
COPY --from=builder /app/payload/src/payload.config.ts ./payload.config.ts
35+
ENV PAYLOAD_CONFIG_PATH=./payload.config.ts
36+
37+
EXPOSE 3000
38+
ENV PORT=3000
39+
ENV NODE_ENV=production
40+
41+
CMD HOSTNAME="0.0.0.0" remix-serve build/server/index.js

examples/remix/website/vite.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ export default defineConfig({
2121
}),
2222
tsconfigPaths(),
2323
],
24+
ssr: {
25+
external: ['sharp'],
26+
// Reduces Docker image size
27+
// https://github.com/remix-run/remix/discussions/8878
28+
noExternal: process.env.NODE_ENV === 'production' ? [/.*/] : [],
29+
},
2430
optimizeDeps: {
2531
exclude: ['sharp', 'file-type'],
2632
},

packages/payload/src/queues/config/collection.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,5 @@ export function jobAfterRead({ config, doc }: { config: SanitizedConfig; doc: Jo
296296
jobLog: doc.log || [],
297297
})
298298
doc.input = doc.input || {}
299-
doc.taskStatus = doc.taskStatus || {}
300299
return doc
301300
}

packages/payload/src/queues/endpoints/run.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ export const runJobsEndpoint: Endpoint = {
6868
silent,
6969
}
7070

71-
if (typeof queue === 'string') {
72-
runJobsArgs.queue = queue
73-
}
74-
7571
const parsedLimit = Number(limit)
7672
if (!isNaN(parsedLimit)) {
7773
runJobsArgs.limit = parsedLimit

packages/payload/src/queues/errors/calculateBackoffWaitUntil.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,22 @@ export function calculateBackoffWaitUntil({
99
retriesConfig: number | RetryConfig
1010
totalTried: number
1111
}): Date {
12-
let waitUntil: Date = getCurrentDate()
12+
const now = getCurrentDate()
13+
let waitUntil: Date = now
14+
1315
if (typeof retriesConfig === 'object') {
1416
if (retriesConfig.backoff) {
1517
if (retriesConfig.backoff.type === 'fixed') {
1618
waitUntil = retriesConfig.backoff.delay
17-
? new Date(getCurrentDate().getTime() + retriesConfig.backoff.delay)
18-
: getCurrentDate()
19+
? new Date(now.getTime() + retriesConfig.backoff.delay)
20+
: now
1921
} else if (retriesConfig.backoff.type === 'exponential') {
2022
// 2 ^ (attempts - 1) * delay (current attempt is not included in totalTried, thus no need for -1)
2123
const delay = retriesConfig.backoff.delay ? retriesConfig.backoff.delay : 0
22-
waitUntil = new Date(getCurrentDate().getTime() + Math.pow(2, totalTried) * delay)
24+
waitUntil = new Date(now.getTime() + Math.pow(2, totalTried) * delay)
2325
}
2426
}
2527
}
2628

27-
/*
28-
const differenceInMSBetweenNowAndWaitUntil = waitUntil.getTime() - getCurrentDate().getTime()
29-
30-
const differenceInSBetweenNowAndWaitUntil = differenceInMSBetweenNowAndWaitUntil / 1000
31-
console.log('Calculated backoff', {
32-
differenceInMSBetweenNowAndWaitUntil,
33-
differenceInSBetweenNowAndWaitUntil,
34-
retriesConfig,
35-
totalTried,
36-
})*/
3729
return waitUntil
3830
}

packages/payload/src/queues/operations/handleSchedules/countRunnableOrActiveJobsForQueue.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import type { PayloadRequest, Where } from '../../../types/index.js'
22
import type { TaskType } from '../../config/types/taskTypes.js'
33
import type { WorkflowTypes } from '../../config/types/workflowTypes.js'
44

5+
import { jobsCollectionSlug } from '../../config/collection.js'
6+
57
/**
68
* Gets all queued jobs that can be run. This means they either:
79
* - failed but do not have a definitive error => can be retried
@@ -63,7 +65,7 @@ export async function countRunnableOrActiveJobsForQueue({
6365
}
6466

6567
const runnableOrActiveJobsForQueue = await req.payload.db.count({
66-
collection: 'payload-jobs',
68+
collection: jobsCollectionSlug,
6769
req,
6870
where: {
6971
and,

packages/payload/src/queues/operations/handleSchedules/defaultAfterSchedule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const defaultAfterSchedule: AfterScheduleFn = async ({ jobStats, queueabl
4040
},
4141
},
4242
},
43-
updatedAt: new Date().toISOString(),
43+
updatedAt: getCurrentDate().toISOString(),
4444
} as JobStats,
4545
req,
4646
returning: false,

packages/payload/src/queues/operations/runJobs/index.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -303,27 +303,22 @@ export const runJobs = async (args: RunJobsArgs): Promise<RunJobsResult> => {
303303
}
304304
}
305305

306-
/**
307-
* Just for logging purposes, we want to know how many jobs are new and how many are existing (= already been tried).
308-
* This is only for logs - in the end we still want to run all jobs, regardless of whether they are new or existing.
309-
*/
310-
const { existingJobs, newJobs } = jobs.reduce(
311-
(acc, job) => {
306+
if (!silent || (typeof silent === 'object' && !silent.info)) {
307+
let newCount = 0
308+
let retryCount = 0
309+
310+
for (const job of jobs) {
312311
if (job.totalTried > 0) {
313-
acc.existingJobs.push(job)
312+
retryCount++
314313
} else {
315-
acc.newJobs.push(job)
314+
newCount++
316315
}
317-
return acc
318-
},
319-
{ existingJobs: [] as Job[], newJobs: [] as Job[] },
320-
)
316+
}
321317

322-
if (!silent || (typeof silent === 'object' && !silent.info)) {
323318
payload.logger.info({
324319
msg: `Running ${jobs.length} jobs.`,
325-
new: newJobs?.length,
326-
retrying: existingJobs?.length,
320+
new: newCount,
321+
retrying: retryCount,
327322
})
328323
}
329324

packages/payload/src/queues/operations/runJobs/runJSONJob/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export const runJSONJob = async ({
137137
return await runJSONJob({
138138
job,
139139
req,
140+
silent,
140141
updateJob,
141142
workflowConfig,
142143
workflowHandler,

0 commit comments

Comments
 (0)