fix(typedsocket): initialize correlation ids for requests without pre-existing correlation metadata
This commit is contained in:
@@ -383,13 +383,19 @@ export class TypedSocket {
|
||||
throw new Error('WebSocket not connected');
|
||||
}
|
||||
|
||||
request.correlation ||= {
|
||||
id: plugins.smartstring.create.createCryptoRandomString(),
|
||||
phase: 'request',
|
||||
};
|
||||
const correlationId = request.correlation.id;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const timeout = setTimeout(() => {
|
||||
this.pendingRequests.delete(request.correlation.id);
|
||||
this.pendingRequests.delete(correlationId);
|
||||
reject(new Error('Request timeout'));
|
||||
}, 30000);
|
||||
|
||||
this.pendingRequests.set(request.correlation.id, {
|
||||
this.pendingRequests.set(correlationId, {
|
||||
resolve: (response) => {
|
||||
clearTimeout(timeout);
|
||||
resolve(response);
|
||||
|
||||
Reference in New Issue
Block a user