Skip to content

Commit 65ad028

Browse files
Merge branch 'master' into minor
2 parents 0bef00b + 338a61e commit 65ad028

File tree

34 files changed

+405
-218
lines changed

34 files changed

+405
-218
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
## <small>3.1.3 (2025-02-14)</small>
2+
3+
4+
#### Fixes
5+
6+
* **admin-ui** Improve display of OrderLine custom fields in form ([4e92d85](https://github.com/vendure-ecommerce/vendure/commit/4e92d85))
7+
* **core** Allow non-public customOrderLineFields in admin api (#3357) ([becfe9d](https://github.com/vendure-ecommerce/vendure/commit/becfe9d)), closes [#3357](https://github.com/vendure-ecommerce/vendure/issues/3357)
8+
* **core** Fix undefined type issue with nested fragment spreads (#3351) ([d0c0454](https://github.com/vendure-ecommerce/vendure/commit/d0c0454)), closes [#3351](https://github.com/vendure-ecommerce/vendure/issues/3351)
9+
10+
#### Perf
11+
12+
* **core** Optimize payload of apply-collection-filters job ([4157033](https://github.com/vendure-ecommerce/vendure/commit/4157033))
13+
* **core** Optimize payload size for buffered jobs in DB ([f81a908](https://github.com/vendure-ecommerce/vendure/commit/f81a908))
14+
* **job-queue-plugin** Optimize payload size for buffered jobs in Redis ([7c72352](https://github.com/vendure-ecommerce/vendure/commit/7c72352))
15+
116
## <small>3.1.2 (2025-01-22)</small>
217

318

docs/docs/guides/developer-guide/plugins/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ By convention, we'll store the entity definitions in the `entities` directory of
216216

217217
```ts title="src/plugins/wishlist-plugin/entities/wishlist-item.entity.ts"
218218
import { DeepPartial, ID, ProductVariant, VendureEntity, EntityId } from '@vendure/core';
219-
import { Column, Entity, ManyToOne } from 'typeorm';
219+
import { Entity, ManyToOne } from 'typeorm';
220220

221221
@Entity()
222222
export class WishlistItem extends VendureEntity {
@@ -727,7 +727,7 @@ We can then query the wishlist items:
727727

728728

729729
<Tabs>
730-
<TabItem value="GetWishlist mutation" label="GetWishlist mutation" default>
730+
<TabItem value="GetWishlist query" label="GetWishlist query" default>
731731

732732
```graphql
733733
query GetWishlist {

docs/docs/guides/developer-guide/worker-job-queue/index.mdx

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ export class ProductVideoPlugin {}
324324

325325
### Passing the RequestContext
326326

327-
It is common to need to pass the [RequestContext object](/reference/typescript-api/request/request-context) to the `process` function of a job, since `ctx` is required by many Vendure
327+
Sometimes you need to pass the [RequestContext object](/reference/typescript-api/request/request-context) to the `process` function of a job, since `ctx` is required by many Vendure
328328
service methods that you may be using inside your `process` function. However, the `RequestContext` object itself is not serializable,
329329
so it cannot be passed directly to the `JobQueue.add()` method. Instead, you can serialize the `RequestContext` using the [`RequestContext.serialize()`
330330
method](/reference/typescript-api/request/request-context/#serialize), and then deserialize it in the `process` function using the static `deserialize` method:
@@ -363,6 +363,59 @@ class ProductExportService implements OnModuleInit {
363363
}
364364
```
365365

366+
:::warning
367+
Serializing the RequestContext should be done with caution, since it is a relatively large object and will significantly increase the size of the job data.
368+
369+
In cases where the job is created in large quantities (hundreds or thousands of jobs per day), this can lead to performance issues. Especially
370+
when using the [BullMQJobQueuePlugin](/reference/core-plugins/job-queue-plugin/bull-mqjob-queue-plugin/), which stores the job data in Redis, the
371+
size of the job data can lead to too much memory usage which can cause the Redis server to crash.
372+
:::
373+
374+
Instead of serializing the entire RequestContext, consider passing only the necessary data you need and then reconstructing the RequestContext in the `process` function:
375+
376+
```ts
377+
import { Injectable, OnModuleInit } from '@nestjs/common';
378+
import { JobQueue, JobQueueService,
379+
RequestContext, ID, LanguageCode, RequestContextService } from '@vendure/core';
380+
381+
@Injectable()
382+
class ProductExportService implements OnModuleInit {
383+
384+
// highlight-next-line
385+
private jobQueue: JobQueue<{ channelToken: string; languageCode: LanguageCode; }>;
386+
387+
constructor(private jobQueueService: JobQueueService,
388+
private requestContextService: RequestContextService) {
389+
}
390+
391+
async onModuleInit() {
392+
this.jobQueue = await this.jobQueueService.createQueue({
393+
name: 'export-products',
394+
process: async job => {
395+
// highlight-start
396+
// Reconstruct the RequestContext from the passed data
397+
const ctx = await this.requestContextService.create({
398+
channelOrToken: job.data.channelToken,
399+
languageCode: job.data.languageCode,
400+
})
401+
// highlight-end
402+
// ... logic to export the product omitted for brevity
403+
},
404+
});
405+
}
406+
407+
exportAllProducts(ctx: RequestContext) {
408+
// highlight-start
409+
// Pass only the necessary data
410+
return this.jobQueue.add({
411+
channelId: ctx.channel.token,
412+
languageCode: ctx.languageCode
413+
});
414+
// highlight-end
415+
}
416+
}
417+
```
418+
366419
### Handling job cancellation
367420

368421
It is possible for an administrator to cancel a running job. Doing so will cause the configured job queue strategy to mark the job as cancelled, but

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"packages": ["packages/*"],
3-
"version": "3.1.2",
3+
"version": "3.1.3",
44
"npmClient": "npm",
55
"command": {
66
"version": {

license/signatures/version1/cla.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,30 @@
479479
"created_at": "2025-02-07T12:21:59Z",
480480
"repoId": 136938012,
481481
"pullRequestNo": 3351
482+
},
483+
{
484+
"name": "kamui",
485+
"id": 2255,
486+
"comment_id": 2649402776,
487+
"created_at": "2025-02-10T22:30:15Z",
488+
"repoId": 136938012,
489+
"pullRequestNo": 3359
490+
},
491+
{
492+
"name": "hooooooouzx",
493+
"id": 50389824,
494+
"comment_id": 2656943842,
495+
"created_at": "2025-02-13T15:22:59Z",
496+
"repoId": 136938012,
497+
"pullRequestNo": 3363
498+
},
499+
{
500+
"name": "Ryrahul",
501+
"id": 121729670,
502+
"comment_id": 2657081786,
503+
"created_at": "2025-02-13T16:09:46Z",
504+
"repoId": 136938012,
505+
"pullRequestNo": 3365
482506
}
483507
]
484508
}

0 commit comments

Comments
 (0)