-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(jsii-dotnet-runtime): Fix EPIPE on Windows.
* The JSII runtime for DotNet applications did not properly dispose of the IO streams in use for communication between the dotnet and jsii processes. This has been fixed, which solves the EPIPE error. * During this invesigation, it was found that the DotNet runtime did not redirect stderr, which disabled the use of JSII_DEBUG. Fixed. * If the node process is closed unexpectedly, the application will now throw an exception with the contents of STDERR. * Added Unit Test for node process closing unexpectedly. * Added gitignore rule for "dist" folders, which are created by pack. Fixes aws#341
- Loading branch information
Showing
9 changed files
with
91 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ node_modules/ | |
.BUILD_COMPLETED | ||
lerna-debug.log | ||
.DS_Store | ||
.idea | ||
.idea | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,4 @@ coverage/ | |
bin/ | ||
cli/ | ||
obj/ | ||
*.DotSettings.user |
2 changes: 1 addition & 1 deletion
2
...sii-dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Amazon.JSII.Runtime.UnitTests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Client/RuntimeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.IO; | ||
using Amazon.JSII.Runtime.Services; | ||
using NSubstitute; | ||
using NSubstitute.ReturnsExtensions; | ||
using Xunit; | ||
|
||
namespace Amazon.JSII.Runtime.UnitTests.Client | ||
{ | ||
public class RuntimeTests | ||
{ | ||
private const string Prefix = "Runtime."; | ||
|
||
private INodeProcess _nodeProcessMock; | ||
private TextReader _standardOutputMock; | ||
private TextReader _standardErrorMock; | ||
|
||
private IRuntime _sut; | ||
|
||
public RuntimeTests() | ||
{ | ||
_nodeProcessMock = Substitute.For<INodeProcess>(); | ||
_standardOutputMock = Substitute.For<TextReader>(); | ||
_standardErrorMock = Substitute.For<TextReader>(); | ||
|
||
_nodeProcessMock.StandardOutput.Returns(_standardOutputMock); | ||
_nodeProcessMock.StandardError.Returns(_standardErrorMock); | ||
|
||
_sut = new Services.Runtime(_nodeProcessMock); | ||
} | ||
|
||
[Fact(DisplayName = Prefix + nameof(ThrowsJsiiExceptionWhenResponseNotReceived))] | ||
public void ThrowsJsiiExceptionWhenResponseNotReceived() | ||
{ | ||
_nodeProcessMock.StandardOutput.ReadLine().ReturnsNull(); | ||
_nodeProcessMock.StandardError.ReadToEnd().Returns("This is a test."); | ||
|
||
var ex = Assert.Throws<JsiiException>(() => _sut.ReadResponse()); | ||
Assert.Equal("Child process exited unexpectedly: This is a test.", ex.Message); | ||
} | ||
} | ||
} |
8 changes: 6 additions & 2 deletions
8
packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/JsiiException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters