Skip to content

Commit 5f88f77

Browse files
fix: platform agent spin p issue (#1137)
Signed-off-by: bhavanakarwade <[email protected]>
1 parent e4f076e commit 5f88f77

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

libs/common/src/NATSClient.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { map } from 'rxjs/operators';
66
import * as nats from 'nats';
77
import { firstValueFrom } from 'rxjs';
88
import ContextStorageService, { ContextStorageServiceKey } from '@credebl/context/contextStorageService.interface';
9+
import { v4 } from 'uuid';
910

1011
@Injectable()
1112
export class NATSClient {
@@ -45,7 +46,13 @@ sendNatsMessage(serviceProxy: ClientProxy, cmd: string, payload: any): Promise<a
4546
}
4647

4748
send<T>(serviceProxy: ClientProxy, pattern: object, payload: any): Promise<T> {
48-
const headers = nats.headers(1, this.contextStorageService.getContextId());
49+
let contextId = this.contextStorageService.getContextId();
50+
51+
if (!contextId) {
52+
contextId = v4();
53+
}
54+
55+
const headers = nats.headers(1, contextId);
4956
const record = new NatsRecordBuilder(payload).setHeaders(headers).build();
5057

5158
const result = serviceProxy.send<T>(pattern, record);

0 commit comments

Comments
 (0)