bunqueue 2.8.22 → 2.8.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -656,14 +656,17 @@ export class QueueManager {
656
656
  const childJob = await this.getJob(childJobId);
657
657
  if (!childJob)
658
658
  return;
659
+ const parentJob = await this.getJob(parentJobId);
659
660
  // Update domain parentId field (cast to bypass readonly for flow linkage)
660
661
  childJob.parentId = parentJobId;
661
- // Update the job's data to include parent reference
662
+ // Update the job's data to include parent reference. __parentQueue must be
663
+ // the PARENT's queue — it feeds buildParentKey/extractParent/buildParentOpts
664
+ // for child→parent navigation (Job.parent, .parentKey, .opts.parent, toJSON).
665
+ // Using the child's own queue corrupted cross-queue flows (audit #102 follow-up).
662
666
  const jobData = childJob.data;
663
667
  jobData.__parentId = parentJobId;
664
- jobData.__parentQueue = childJob.queue;
668
+ jobData.__parentQueue = parentJob?.queue ?? jobData.__parentQueue ?? childJob.queue;
665
669
  // Also add this child to parent's childrenIds
666
- const parentJob = await this.getJob(parentJobId);
667
670
  if (parentJob) {
668
671
  if (!parentJob.childrenIds) {
669
672
  parentJob.childrenIds = [];
@@ -196,7 +196,17 @@ export class FlowProducer extends EventEmitter {
196
196
  __flowParentIds: parallelIds,
197
197
  ...final.data,
198
198
  };
199
- const finalId = await pushJob(this.pushCtx, final.queueName, finalData, final.opts ?? {}, parallelIds);
199
+ // pushJobWithParent (not pushJob) so the final job records childrenIds =
200
+ // parallelIds: this keeps the same dependsOn ordering (waits for all
201
+ // parallel jobs) AND lets the merge step read their results via
202
+ // getChildrenValues()/getDependencies(), like a BullMQ fan-in parent.
203
+ const finalId = await pushJobWithParent(this.pushCtx, {
204
+ queueName: final.queueName,
205
+ data: finalData,
206
+ opts: final.opts ?? {},
207
+ parentRef: null,
208
+ childIds: parallelIds,
209
+ });
200
210
  return { parallelIds, finalId };
201
211
  }
202
212
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunqueue",
3
- "version": "2.8.22",
3
+ "version": "2.8.23",
4
4
  "description": "High-performance job queue for Bun & AI agents. SQLite persistence, cron scheduling, priorities, retries, DLQ, webhooks, native MCP server. Zero external dependencies.",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",