@olane/o-node 0.7.12-alpha.66 → 0.7.12-alpha.67
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.
- package/dist/src/connection/o-node-connection.d.ts.map +1 -1
- package/dist/src/connection/o-node-connection.js +2 -1
- package/dist/src/connection/stream-handler.d.ts +2 -1
- package/dist/src/connection/stream-handler.d.ts.map +1 -1
- package/dist/src/connection/stream-handler.js +9 -9
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-node-connection.d.ts","sourceRoot":"","sources":["../../../src/connection/o-node-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAEL,WAAW,EAGX,QAAQ,EACR,SAAS,EACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,qBAAa,eAAgB,SAAQ,WAAW;IAIlC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,qBAAqB;IAHrD,aAAa,EAAE,UAAU,CAAC;IACjC,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC;gBAER,MAAM,EAAE,qBAAqB;IAO5D,wBAAwB;IAYxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM;IAmBlB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAkBpC,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"o-node-connection.d.ts","sourceRoot":"","sources":["../../../src/connection/o-node-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAEL,WAAW,EAGX,QAAQ,EACR,SAAS,EACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,qBAAa,eAAgB,SAAQ,WAAW;IAIlC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,qBAAqB;IAHrD,aAAa,EAAE,UAAU,CAAC;IACjC,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC;gBAER,MAAM,EAAE,qBAAqB;IAO5D,wBAAwB;IAYxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM;IAmBlB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAkBpC,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IA0C/C,YAAY,CAAC,MAAM,EAAE,MAAM;IAQ3B,KAAK,CAAC,KAAK,EAAE,KAAK;IAMlB,KAAK;CAKZ"}
|
|
@@ -56,7 +56,8 @@ export class oNodeConnection extends oConnection {
|
|
|
56
56
|
await this.streamHandler.send(stream, data, streamConfig);
|
|
57
57
|
// Handle response using StreamHandler
|
|
58
58
|
// Pass request handler if configured to enable bidirectional stream processing
|
|
59
|
-
|
|
59
|
+
// Pass request ID to enable proper response correlation on shared streams
|
|
60
|
+
const response = await this.streamHandler.handleOutgoingStream(stream, this.emitter, streamConfig, this.config.requestHandler, request.id);
|
|
60
61
|
// Handle cleanup of the stream
|
|
61
62
|
await this.postTransmit(stream);
|
|
62
63
|
return response;
|
|
@@ -81,9 +81,10 @@ export declare class StreamHandler {
|
|
|
81
81
|
* @param emitter - Event emitter for chunk events
|
|
82
82
|
* @param config - Configuration including abort signal
|
|
83
83
|
* @param requestHandler - Optional handler for processing router requests received on this stream
|
|
84
|
+
* @param requestId - Optional request ID to filter responses (for stream reuse scenarios)
|
|
84
85
|
* @returns Promise that resolves with the final response
|
|
85
86
|
*/
|
|
86
|
-
handleOutgoingStream(stream: Stream, emitter: EventEmitter, config?: StreamHandlerConfig, requestHandler?: (request: oRequest, stream: Stream) => Promise<RunResult
|
|
87
|
+
handleOutgoingStream(stream: Stream, emitter: EventEmitter, config?: StreamHandlerConfig, requestHandler?: (request: oRequest, stream: Stream) => Promise<RunResult>, requestId?: string | number): Promise<oResponse>;
|
|
87
88
|
/**
|
|
88
89
|
* Forwards a request to the next hop and relays response chunks back
|
|
89
90
|
* This implements the middleware/proxy pattern for intermediate nodes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-handler.d.ts","sourceRoot":"","sources":["../../../src/connection/stream-handler.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EACL,QAAQ,EACR,SAAS,EAIT,MAAM,EAEP,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGtE;;;;;;;GAOG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,CAAC,EAAE,MAAM;IAI3B;;;OAGG;IACH,SAAS,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;IAIhC;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;IAIjC;;OAEG;IACG,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAI7C;;;;;;OAMG;IACG,iBAAiB,CACrB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,mBAAwB,GAC/B,OAAO,CAAC,MAAM,CAAC;
|
|
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EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,CAAC,GACtE,OAAO,CAAC,IAAI,CAAC;IAuChB;;;;;;OAMG;YACW,oBAAoB;IA4BlC;;;;;;;;;;;OAWG;IACG,oBAAoB,CACxB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,YAAY,EACrB,MAAM,GAAE,mBAAwB,EAChC,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,CAAC,EAC1E,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAC1B,OAAO,CAAC,SAAS,CAAC;IA+GrB;;;;;;;OAOG;IACG,cAAc,CAClB,OAAO,EAAE,cAAc,EACvB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,GAChD,OAAO,CAAC,IAAI,CAAC;CAyBjB"}
|
|
@@ -46,13 +46,6 @@ export class StreamHandler {
|
|
|
46
46
|
this.logger.debug('Reuse policy:', reusePolicy);
|
|
47
47
|
// Check for existing stream if reuse is enabled
|
|
48
48
|
if (reusePolicy === 'reuse') {
|
|
49
|
-
this.logger.debug('Reusing existing stream if we can find one. Stream insights:', JSON.stringify({
|
|
50
|
-
streamCount: connection.streams.length,
|
|
51
|
-
protocol: protocol,
|
|
52
|
-
}));
|
|
53
|
-
connection.streams.forEach((stream) => {
|
|
54
|
-
this.logger.debug('Stream re-use option:', stream.protocol, stream.status, stream.direction, stream.remoteWriteStatus, stream.writeStatus, stream.remoteReadStatus, stream.readStatus);
|
|
55
|
-
});
|
|
56
49
|
const existingStream = connection.streams.find((stream) => stream.status === 'open' &&
|
|
57
50
|
stream.protocol === protocol &&
|
|
58
51
|
stream.writeStatus === 'writable' &&
|
|
@@ -190,9 +183,10 @@ export class StreamHandler {
|
|
|
190
183
|
* @param emitter - Event emitter for chunk events
|
|
191
184
|
* @param config - Configuration including abort signal
|
|
192
185
|
* @param requestHandler - Optional handler for processing router requests received on this stream
|
|
186
|
+
* @param requestId - Optional request ID to filter responses (for stream reuse scenarios)
|
|
193
187
|
* @returns Promise that resolves with the final response
|
|
194
188
|
*/
|
|
195
|
-
async handleOutgoingStream(stream, emitter, config = {}, requestHandler) {
|
|
189
|
+
async handleOutgoingStream(stream, emitter, config = {}, requestHandler, requestId) {
|
|
196
190
|
return new Promise((resolve, reject) => {
|
|
197
191
|
let lastResponse;
|
|
198
192
|
const messageHandler = async (event) => {
|
|
@@ -211,9 +205,15 @@ export class StreamHandler {
|
|
|
211
205
|
}
|
|
212
206
|
if (this.isResponse(message)) {
|
|
213
207
|
const response = await CoreUtils.processStreamResponse(event);
|
|
208
|
+
// If requestId is provided, filter responses to only process those matching our request
|
|
209
|
+
// This prevents premature termination when multiple requests share the same stream
|
|
210
|
+
if (requestId !== undefined && response.id !== requestId) {
|
|
211
|
+
this.logger.debug(`Ignoring response for different request (expected: ${requestId}, received: ${response.id})`);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
214
|
// Emit chunk for streaming responses
|
|
215
215
|
emitter.emit('chunk', response);
|
|
216
|
-
// Check if this is the last chunk
|
|
216
|
+
// Check if this is the last chunk for THIS request
|
|
217
217
|
if (response.result._last || !response.result._isStreaming) {
|
|
218
218
|
lastResponse = response;
|
|
219
219
|
cleanup();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/o-node",
|
|
3
|
-
"version": "0.7.12-alpha.
|
|
3
|
+
"version": "0.7.12-alpha.67",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
"typescript": "5.4.5"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@olane/o-config": "0.7.12-alpha.
|
|
58
|
-
"@olane/o-core": "0.7.12-alpha.
|
|
59
|
-
"@olane/o-protocol": "0.7.12-alpha.
|
|
60
|
-
"@olane/o-tool": "0.7.12-alpha.
|
|
57
|
+
"@olane/o-config": "0.7.12-alpha.67",
|
|
58
|
+
"@olane/o-core": "0.7.12-alpha.67",
|
|
59
|
+
"@olane/o-protocol": "0.7.12-alpha.67",
|
|
60
|
+
"@olane/o-tool": "0.7.12-alpha.67",
|
|
61
61
|
"debug": "^4.4.1",
|
|
62
62
|
"dotenv": "^16.5.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "f881834d2a73537cef03f795fb0cf175181e9900"
|
|
65
65
|
}
|