@mastra/memory 1.17.3 → 1.17.4

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.
@@ -4624,13 +4624,19 @@ var ReflectorRunner = class {
4624
4624
  const bufferKey = this.buffering.getReflectionBufferKey(lockKey);
4625
4625
  const asyncOp = BufferingCoordinator.asyncBufferingOps.get(bufferKey);
4626
4626
  if (asyncOp) {
4627
- omDebug(`[OM:reflect] tryActivateBufferedReflection: waiting for in-progress op...`);
4628
- try {
4629
- await Promise.race([
4630
- asyncOp,
4631
- new Promise((_, reject) => setTimeout(() => reject(new Error("Timeout")), 6e4))
4632
- ]);
4633
- } catch {
4627
+ if (activationMetadata?.triggeredBy === "ttl" || activationMetadata?.triggeredBy === "provider_change") {
4628
+ omDebug(
4629
+ `[OM:reflect] tryActivateBufferedReflection: async op in progress, not blocking for ${activationMetadata.triggeredBy} trigger`
4630
+ );
4631
+ } else {
4632
+ omDebug(`[OM:reflect] tryActivateBufferedReflection: waiting for in-progress op...`);
4633
+ try {
4634
+ await Promise.race([
4635
+ asyncOp,
4636
+ new Promise((_, reject) => setTimeout(() => reject(new Error("Timeout")), 5e3))
4637
+ ]);
4638
+ } catch {
4639
+ }
4634
4640
  }
4635
4641
  }
4636
4642
  const freshRecord = await this.storage.getObservationalMemory(record.threadId, record.resourceId);
@@ -9171,6 +9177,15 @@ var ObservationalMemoryProcessor = class {
9171
9177
  if (readOnly) {
9172
9178
  return messageList;
9173
9179
  }
9180
+ const activeTurn = state.__omTurn ?? this.turn;
9181
+ if (activeTurn && activeTurn.messageList !== messageList) {
9182
+ await activeTurn.end().catch(() => {
9183
+ });
9184
+ if (this.turn === activeTurn) {
9185
+ this.turn = void 0;
9186
+ }
9187
+ state.__omTurn = void 0;
9188
+ }
9174
9189
  if (!this.turn || !state.__omTurn) {
9175
9190
  if (this.turn && !state.__omTurn) {
9176
9191
  await this.turn.end().catch(() => {
@@ -9360,5 +9375,5 @@ exports.stripEphemeralAnchorIds = stripEphemeralAnchorIds;
9360
9375
  exports.stripObservationGroups = stripObservationGroups;
9361
9376
  exports.truncateStringByTokens = truncateStringByTokens;
9362
9377
  exports.wrapInObservationGroup = wrapInObservationGroup;
9363
- //# sourceMappingURL=chunk-J2XQSPAB.cjs.map
9364
- //# sourceMappingURL=chunk-J2XQSPAB.cjs.map
9378
+ //# sourceMappingURL=chunk-M6QU3KKP.cjs.map
9379
+ //# sourceMappingURL=chunk-M6QU3KKP.cjs.map