@pikku/mongodb 0.12.25 → 0.12.27

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.
@@ -8,7 +8,7 @@ export declare class MongoDBChannelStore extends ChannelStore {
8
8
  private subscriptions;
9
9
  constructor(db: Db);
10
10
  init(): Promise<void>;
11
- addChannel({ channelId, channelName, openingData, }: Channel): Promise<void>;
11
+ addChannel({ channelId, channelName, openingData, traceparent, }: Channel): Promise<void>;
12
12
  removeChannels(channelIds: string[]): Promise<void>;
13
13
  setPikkuUserId(channelId: string, pikkuUserId: string | null): Promise<void>;
14
14
  getChannel(channelId: string): Promise<Channel & {
@@ -17,11 +17,12 @@ export class MongoDBChannelStore extends ChannelStore {
17
17
  await this.subscriptions.createIndex({ topic: 1 });
18
18
  this.initialized = true;
19
19
  }
20
- async addChannel({ channelId, channelName, openingData, }) {
20
+ async addChannel({ channelId, channelName, openingData, traceparent, }) {
21
21
  await this.channels.insertOne({
22
22
  _id: channelId,
23
23
  channelName,
24
24
  openingData: openingData || {},
25
+ ...(traceparent ? { traceparent } : {}),
25
26
  pikkuUserId: null,
26
27
  createdAt: new Date(),
27
28
  lastWire: new Date(),
@@ -45,6 +46,7 @@ export class MongoDBChannelStore extends ChannelStore {
45
46
  channelId: row._id,
46
47
  channelName: row.channelName,
47
48
  openingData: row.openingData ?? {},
49
+ traceparent: row.traceparent,
48
50
  pikkuUserId: row.pikkuUserId ?? undefined,
49
51
  };
50
52
  }
@@ -16,6 +16,6 @@ export declare class MongoDBDeploymentService implements DeploymentService {
16
16
  init(): Promise<void>;
17
17
  start(config: DeploymentConfig): Promise<void>;
18
18
  stop(): Promise<void>;
19
- invoke(funcName: string, data: unknown, session?: unknown, traceId?: string): Promise<unknown>;
19
+ invoke(funcName: string, data: unknown, session?: unknown, traceparent?: string): Promise<unknown>;
20
20
  private sendHeartbeat;
21
21
  }
@@ -56,8 +56,8 @@ export class MongoDBDeploymentService {
56
56
  });
57
57
  }
58
58
  }
59
- async invoke(funcName, data, session, traceId) {
60
- const headers = await buildMeshHeaders(this.jwt, this.secrets, funcName, session, traceId);
59
+ async invoke(funcName, data, session, traceparent) {
60
+ const headers = await buildMeshHeaders(this.jwt, this.secrets, funcName, session, traceparent);
61
61
  const cutoff = new Date(Date.now() - this.heartbeatTtl);
62
62
  const result = await this.deployments.findOne({ functions: funcName, lastHeartbeat: { $gt: cutoff } }, { sort: { lastHeartbeat: -1 } });
63
63
  if (!result) {
@@ -285,6 +285,7 @@ export class MongoDBWorkflowService extends PikkuWorkflowService {
285
285
  return null;
286
286
  }
287
287
  await this.setStepError(stepState.stepId, new WorkflowStepLeaseExpiredError(runId, stepName, stepState.attemptCount), stepState.attemptCount);
288
+ await this.logStepAttemptsExhausted(runId, stepName, stepState.attemptCount);
288
289
  // A null claim reads as "another dispatch owns it", so nothing else
289
290
  // would requeue the orchestrator to see this failure.
290
291
  await this.resumeWorkflow(runId);
@@ -296,7 +297,7 @@ export class MongoDBWorkflowService extends PikkuWorkflowService {
296
297
  return null;
297
298
  }
298
299
  if (stepState.status === 'failed' || stepState.status === 'running') {
299
- return this.mirrored(() => this.reclaimStepAttempt(stepState, leaseMs), async (mirror, newStep) => {
300
+ const reclaimed = await this.mirrored(() => this.reclaimStepAttempt(stepState, leaseMs), async (mirror, newStep) => {
300
301
  if (newStep) {
301
302
  await mirror.createRetryAttempt(stepState.stepId, {
302
303
  ...newStep,
@@ -304,6 +305,11 @@ export class MongoDBWorkflowService extends PikkuWorkflowService {
304
305
  });
305
306
  }
306
307
  });
308
+ // A `failed` step threw, and this is its ordinary retry.
309
+ if (reclaimed && stepState.status === 'running') {
310
+ await this.logStepRerun(runId, stepName, reclaimed.attemptCount);
311
+ }
312
+ return reclaimed;
307
313
  }
308
314
  if (stepState.status === 'pending' || stepState.status === 'scheduled') {
309
315
  if (!(await this.claimStepStatus(stepState, ['pending', 'scheduled'], leaseMs))) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/mongodb",
3
- "version": "0.12.25",
3
+ "version": "0.12.27",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/pikkujs/pikku.git",
@@ -24,7 +24,7 @@
24
24
  "clean": "rm -rf dist tsconfig.tsbuildinfo"
25
25
  },
26
26
  "peerDependencies": {
27
- "@pikku/core": "^0.12.146"
27
+ "@pikku/core": "^0.12.151"
28
28
  },
29
29
  "dependencies": {
30
30
  "mongodb": "^7.7.0"