diff --git a/Changelog.md b/Changelog.md
index a324dbd..cfa2498 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -3,7 +3,11 @@ This project uses [semantic versioning](http://semver.org/spec/v2.0.0.html). Ref
*[Semantic Versioning in Practice](https://www.jering.tech/articles/semantic-versioning-in-practice)*
for an overview of semantic versioning.
-## [Unreleased](https://github.com/JeringTech/Javascript.NodeJS/compare/5.3.1...HEAD)
+## [Unreleased](https://github.com/JeringTech/Javascript.NodeJS/compare/5.3.2...HEAD)
+
+## [5.3.2](https://github.com/JeringTech/Javascript.NodeJS/compare/5.3.1...5.3.2) - Feb 22, 2020
+### Fixes
+- `HttpNodeJSService` no longer disposes `Stream`s before returning them. ([#73](https://github.com/JeringTech/Javascript.NodeJS/pull/73)).
## [5.3.1](https://github.com/JeringTech/Javascript.NodeJS/compare/5.3.0...5.3.1) - Feb 12, 2020
### Fixes
diff --git a/perf/NodeJS/Jering.Javascript.NodeJS.Performance.csproj b/perf/NodeJS/Jering.Javascript.NodeJS.Performance.csproj
index 9f66053..d1d2202 100644
--- a/perf/NodeJS/Jering.Javascript.NodeJS.Performance.csproj
+++ b/perf/NodeJS/Jering.Javascript.NodeJS.Performance.csproj
@@ -13,7 +13,7 @@
-
+
diff --git a/perf/NodeJS/packages.lock.json b/perf/NodeJS/packages.lock.json
index 80f9fef..8052af5 100644
--- a/perf/NodeJS/packages.lock.json
+++ b/perf/NodeJS/packages.lock.json
@@ -32,9 +32,9 @@
},
"Yarn.MSBuild": {
"type": "Direct",
- "requested": "[1.16.0, )",
- "resolved": "1.16.0",
- "contentHash": "JzrCeiEMGjkw+z4JvOeZMWmhJF7YI7KDPXglg7PRtFqqBarLFiwGXsMPmiJQ+tXxFNfdBX8KmfDX0KT8htZjZw=="
+ "requested": "[1.22.0, )",
+ "resolved": "1.22.0",
+ "contentHash": "+uECXuuZ+8kjNR8bF6Y8wyKiDbrI/MSX9VTuE0q1GcRm13vU7IZl4WUfXSb/3aHmxsDsWGZxktfEnwe2YWgugg=="
},
"BenchmarkDotNet.Annotations": {
"type": "Transitive",
diff --git a/src/NodeJS/Jering.Javascript.NodeJS.csproj b/src/NodeJS/Jering.Javascript.NodeJS.csproj
index b063eaf..c5aa956 100644
--- a/src/NodeJS/Jering.Javascript.NodeJS.csproj
+++ b/src/NodeJS/Jering.Javascript.NodeJS.csproj
@@ -53,7 +53,7 @@
runtime; build; native; contentfiles; analyzers
-
+
compile; build; native; contentfiles; analyzers; buildtransitive
@@ -86,11 +86,11 @@
So we must specify both. This way if we are multi-targeting, JavascriptBuild runs once, before DispatchToInnerBuilds after which inputs == outputs.
If we aren't multi-targeting, JavascriptBuild runs before PreBuildEvent.
-->
-
+
-
+
diff --git a/src/NodeJS/NodeJSServiceImplementations/OutOfProcess/Http/HttpNodeJSService.cs b/src/NodeJS/NodeJSServiceImplementations/OutOfProcess/Http/HttpNodeJSService.cs
index b968052..58cd5eb 100644
--- a/src/NodeJS/NodeJSServiceImplementations/OutOfProcess/Http/HttpNodeJSService.cs
+++ b/src/NodeJS/NodeJSServiceImplementations/OutOfProcess/Http/HttpNodeJSService.cs
@@ -104,15 +104,15 @@ public HttpNodeJSService(IOptions outOfProcess
return (true, (T)(object)result);
}
- using (Stream stream = await httpResponseMessage.Content.ReadAsStreamAsync().ConfigureAwait(false))
+ if (typeof(T) == typeof(Stream))
{
- if (typeof(T) == typeof(Stream))
- {
- return (true, (T)(object)stream);
- }
+ Stream stream = await httpResponseMessage.Content.ReadAsStreamAsync().ConfigureAwait(false);
+ return (true, (T)(object)stream); // User's reponsibility to handle disposal
+ }
+ using (Stream stream = await httpResponseMessage.Content.ReadAsStreamAsync().ConfigureAwait(false))
+ {
T result = await _jsonService.DeserializeAsync(stream, cancellationToken).ConfigureAwait(false);
-
return (true, result);
}
}
diff --git a/src/NodeJS/packages.lock.json b/src/NodeJS/packages.lock.json
index 40d0182..b6116f8 100644
--- a/src/NodeJS/packages.lock.json
+++ b/src/NodeJS/packages.lock.json
@@ -93,9 +93,9 @@
},
"Yarn.MSBuild": {
"type": "Direct",
- "requested": "[1.16.0, )",
- "resolved": "1.16.0",
- "contentHash": "JzrCeiEMGjkw+z4JvOeZMWmhJF7YI7KDPXglg7PRtFqqBarLFiwGXsMPmiJQ+tXxFNfdBX8KmfDX0KT8htZjZw=="
+ "requested": "[1.22.0, )",
+ "resolved": "1.22.0",
+ "contentHash": "+uECXuuZ+8kjNR8bF6Y8wyKiDbrI/MSX9VTuE0q1GcRm13vU7IZl4WUfXSb/3aHmxsDsWGZxktfEnwe2YWgugg=="
},
"Microsoft.AspNetCore.Hosting.Server.Abstractions": {
"type": "Transitive",
@@ -640,9 +640,9 @@
},
"Yarn.MSBuild": {
"type": "Direct",
- "requested": "[1.16.0, )",
- "resolved": "1.16.0",
- "contentHash": "JzrCeiEMGjkw+z4JvOeZMWmhJF7YI7KDPXglg7PRtFqqBarLFiwGXsMPmiJQ+tXxFNfdBX8KmfDX0KT8htZjZw=="
+ "requested": "[1.22.0, )",
+ "resolved": "1.22.0",
+ "contentHash": "+uECXuuZ+8kjNR8bF6Y8wyKiDbrI/MSX9VTuE0q1GcRm13vU7IZl4WUfXSb/3aHmxsDsWGZxktfEnwe2YWgugg=="
},
"Microsoft.AspNetCore.Hosting.Server.Abstractions": {
"type": "Transitive",
diff --git a/test/NodeJS/HttpNodeJSServiceIntegrationTests.cs b/test/NodeJS/HttpNodeJSServiceIntegrationTests.cs
index 676f479..f60fd5c 100644
--- a/test/NodeJS/HttpNodeJSServiceIntegrationTests.cs
+++ b/test/NodeJS/HttpNodeJSServiceIntegrationTests.cs
@@ -983,6 +983,31 @@ public async void AllInvokeMethods_HandleHttpClientErrorsSuchAsMalformedRequests
}
}
+ [Fact]
+ public async void AllInvokeMethodsThatReturnAValue_HandleStreamReturnType()
+ {
+ // Arrange
+ const string dummyData = "dummyData";
+ string dummyModule = $@"var Readable = require('stream').Readable;
+module.exports = (callback) => {{
+ var stream = new Readable();
+ stream.push('{dummyData}');
+ stream.push(null);
+
+ callback(null, stream);
+}}";
+ HttpNodeJSService testSubject = CreateHttpNodeJSService();
+
+ // Act
+ using (Stream resultStream = await testSubject.InvokeFromStringAsync(dummyModule).ConfigureAwait(false))
+ using (var streamReader = new StreamReader(resultStream))
+ {
+ // Assert
+ string result = streamReader.ReadToEnd();
+ Assert.Equal(dummyData, result);
+ }
+ }
+
///
/// Specify for access to all logging output.
///
diff --git a/test/NodeJS/Jering.Javascript.NodeJS.Tests.csproj b/test/NodeJS/Jering.Javascript.NodeJS.Tests.csproj
index 9cdb81a..b8711b7 100644
--- a/test/NodeJS/Jering.Javascript.NodeJS.Tests.csproj
+++ b/test/NodeJS/Jering.Javascript.NodeJS.Tests.csproj
@@ -36,7 +36,7 @@
-
+
diff --git a/test/NodeJS/packages.lock.json b/test/NodeJS/packages.lock.json
index 9a9cd28..6b1485c 100644
--- a/test/NodeJS/packages.lock.json
+++ b/test/NodeJS/packages.lock.json
@@ -92,9 +92,9 @@
},
"Yarn.MSBuild": {
"type": "Direct",
- "requested": "[1.16.0, )",
- "resolved": "1.16.0",
- "contentHash": "JzrCeiEMGjkw+z4JvOeZMWmhJF7YI7KDPXglg7PRtFqqBarLFiwGXsMPmiJQ+tXxFNfdBX8KmfDX0KT8htZjZw=="
+ "requested": "[1.22.0, )",
+ "resolved": "1.22.0",
+ "contentHash": "+uECXuuZ+8kjNR8bF6Y8wyKiDbrI/MSX9VTuE0q1GcRm13vU7IZl4WUfXSb/3aHmxsDsWGZxktfEnwe2YWgugg=="
},
"Castle.Core": {
"type": "Transitive",
@@ -1023,9 +1023,9 @@
},
"Yarn.MSBuild": {
"type": "Direct",
- "requested": "[1.16.0, )",
- "resolved": "1.16.0",
- "contentHash": "JzrCeiEMGjkw+z4JvOeZMWmhJF7YI7KDPXglg7PRtFqqBarLFiwGXsMPmiJQ+tXxFNfdBX8KmfDX0KT8htZjZw=="
+ "requested": "[1.22.0, )",
+ "resolved": "1.22.0",
+ "contentHash": "+uECXuuZ+8kjNR8bF6Y8wyKiDbrI/MSX9VTuE0q1GcRm13vU7IZl4WUfXSb/3aHmxsDsWGZxktfEnwe2YWgugg=="
},
"Castle.Core": {
"type": "Transitive",