nighthouse
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -112,3 +112,3 @@ "use strict"; | ||
this.logger.trace(() => `Registering new stream ${requestId} from ${JSON.stringify(path)}...`); | ||
this.streamsByPath.set(key, { requestIds: [requestId] }); | ||
this.streamsByPath.set(key, { originalId: requestId, requestIds: [requestId] }); | ||
} | ||
@@ -121,7 +121,7 @@ return (async function* () { | ||
finally { | ||
const sr = this.streamsByPath.get(key); | ||
if (sr.requestIds.length > 1) { | ||
const stream = this.streamsByPath.get(key); | ||
if (stream.requestIds.length > 1) { | ||
// This path is still being streamed by another consumer | ||
// TODO: Assert that sr.requestIds contains our request id (once) | ||
this.streamsByPath.set(key, { requestIds: sr.requestIds.filter(id => id !== requestId) }); | ||
this.streamsByPath.set(key, { ...stream, requestIds: stream.requestIds.filter(id => id !== requestId) }); | ||
} | ||
@@ -244,3 +244,3 @@ else { | ||
// No response handler exists (yet?), warn about it. | ||
const demuxedIds = (_b = (_a = [...this.streamsByPath.values()].find(s => s.requestIds.includes(message.REID))) === null || _a === void 0 ? void 0 : _a.requestIds) !== null && _b !== void 0 ? _b : [message.REID]; | ||
const demuxedIds = (_b = (_a = [...this.streamsByPath.values()].find(s => s.originalId === message.REID)) === null || _a === void 0 ? void 0 : _a.requestIds) !== null && _b !== void 0 ? _b : [message.REID]; | ||
this.logger.warning(() => `Got out-of-order event for id ${message.REID}${demuxedIds.length > 1 ? ` (demuxed to ${JSON.stringify(demuxedIds)})` : ''}`); | ||
@@ -247,0 +247,0 @@ for (const id of demuxedIds) { |
{ | ||
"name": "nighthouse", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Lightweight Project Lighthouse client for JavaScript", | ||
@@ -5,0 +5,0 @@ "workspaces": [ |
@@ -14,3 +14,5 @@ import { Transport } from "./transport"; | ||
interface ResourceStream { | ||
/** All request ids that we are listening on for this stream. */ | ||
/** The original request id used to stream from the server. */ | ||
originalId: number; | ||
/** All request ids that are listening for this stream. */ | ||
requestIds: number[]; | ||
@@ -142,3 +144,3 @@ } | ||
this.logger.trace(() => `Registering new stream ${requestId} from ${JSON.stringify(path)}...`); | ||
this.streamsByPath.set(key, { requestIds: [requestId] }); | ||
this.streamsByPath.set(key, { originalId: requestId, requestIds: [requestId] }); | ||
} | ||
@@ -151,7 +153,7 @@ | ||
} finally { | ||
const sr = this.streamsByPath.get(key); | ||
if (sr.requestIds.length > 1) { | ||
const stream = this.streamsByPath.get(key); | ||
if (stream.requestIds.length > 1) { | ||
// This path is still being streamed by another consumer | ||
// TODO: Assert that sr.requestIds contains our request id (once) | ||
this.streamsByPath.set(key, { requestIds: sr.requestIds.filter(id => id !== requestId) }); | ||
this.streamsByPath.set(key, { ...stream, requestIds: stream.requestIds.filter(id => id !== requestId) }); | ||
} else { | ||
@@ -282,3 +284,3 @@ // We were the last consumer to stream this path, so we can stop it | ||
// No response handler exists (yet?), warn about it. | ||
const demuxedIds: number[] = [...this.streamsByPath.values()].find(s => s.requestIds.includes(message.REID))?.requestIds ?? [message.REID]; | ||
const demuxedIds: number[] = [...this.streamsByPath.values()].find(s => s.originalId === message.REID)?.requestIds ?? [message.REID]; | ||
this.logger.warning(() => `Got out-of-order event for id ${message.REID}${demuxedIds.length > 1 ? ` (demuxed to ${JSON.stringify(demuxedIds)})` : ''}`); | ||
@@ -285,0 +287,0 @@ for (const id of demuxedIds) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
147259
1795