Skip to content

Commit 1e196cf

Browse files
author
Xavier Hahn
committed
Merge remote-tracking branch 'upstream/dev' into dev
2 parents 97708ad + a9bc120 commit 1e196cf

File tree

27 files changed

+114
-41
lines changed

27 files changed

+114
-41
lines changed

appveyor.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ artifacts:
2828
# - build.cmd verify
2929
clone_depth: 1
3030
test_script:
31-
- dotnet restore ./src
32-
- npm install -g selenium-standalone
33-
- selenium-standalone install
31+
# - dotnet restore ./src
32+
# - npm install -g selenium-standalone
33+
# - selenium-standalone install
3434
# The nosys flag is needed for selenium to work on Appveyor
35-
- ps: Start-Process selenium-standalone 'start','--','-Djna.nosys=true'
36-
- ps: Push-Location
37-
- cd test
38-
- npm install
39-
- npm test
35+
# - ps: Start-Process selenium-standalone 'start','--','-Djna.nosys=true'
36+
# - ps: Push-Location
37+
# - cd test
38+
# - npm install
39+
# - npm test
4040
on_finish :
41-
- ps: Pop-Location
41+
# - ps: Pop-Location
4242
# After running tests, upload results to Appveyor
43-
- ps: (new-object net.webclient).UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\test\tmp\junit\*.xml))
43+
# - ps: (new-object net.webclient).UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\test\tmp\junit\*.xml))
4444
deploy: off

makefile.shade

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,10 @@ var AUTHORS='Microsoft Open Technologies, Inc.'
55
var TEST_PROJECT_GLOB='templates/*/project.json'
66
var SAMPLES_PROJECT_GLOB='samples/misc/*/project.json'
77

8+
@{
9+
// The build quality values are set in each of the project.json files
10+
BuildQuality = "";
11+
}
12+
813
use-standard-lifecycle
914
k-standard-goals

samples/react/MusicStore/ReactApp/configureStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createStore, applyMiddleware, compose, combineReducers, GenericStoreEnhancer } from 'redux';
1+
import { createStore, applyMiddleware, compose, combineReducers, GenericStoreEnhancer, Store as ReduxStore } from 'redux';
22
import thunk from 'redux-thunk';
33
import { routerReducer } from 'react-router-redux';
44
import * as Store from './store';
@@ -16,7 +16,7 @@ export default function configureStore(initialState?: Store.ApplicationState) {
1616

1717
// Combine all reducers and instantiate the app-wide store instance
1818
const allReducers = buildRootReducer(Store.reducers);
19-
const store = createStoreWithMiddleware(allReducers, initialState) as Redux.Store<Store.ApplicationState>;
19+
const store = createStoreWithMiddleware(allReducers, initialState) as ReduxStore<Store.ApplicationState>;
2020

2121
// Enable Webpack hot module replacement for reducers
2222
if (module.hot) {

samples/react/MusicStore/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "music-store",
33
"version": "0.0.0",
44
"dependencies": {
5+
"@types/history": "^2.0.0",
56
"@types/react": "^0.14.29",
67
"@types/react-bootstrap": "^0.0.35",
78
"@types/react-dom": "^0.14.14",
@@ -41,7 +42,7 @@
4142
"redux-typed": "^2.0.0",
4243
"style-loader": "^0.13.0",
4344
"ts-loader": "^0.8.1",
44-
"typescript": "2.0.3",
45+
"typescript": "^2.0.3",
4546
"url-loader": "^0.5.7",
4647
"webpack": "^1.13.2",
4748
"webpack-hot-middleware": "^2.12.2",

samples/react/MusicStore/tsconfig.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
{
22
"compilerOptions": {
3+
"baseUrl": ".",
34
"moduleResolution": "node",
45
"target": "es6",
56
"jsx": "preserve",
67
"sourceMap": true,
78
"experimentalDecorators": true,
8-
"types": [ "webpack-env", "whatwg-fetch" ]
9+
"types": [ "webpack-env", "whatwg-fetch" ],
10+
"paths": {
11+
// Fix "Duplicate identifier" errors caused by multiple dependencies fetching their own copies of type definitions.
12+
// We tell TypeScript which type definitions module to treat as the canonical one (instead of combining all of them).
13+
"history": ["./node_modules/@types/history/index"],
14+
"redux": ["./node_modules/@types/redux/index"],
15+
"react": ["./node_modules/@types/react/index"]
16+
}
917
},
1018
"exclude": [
1119
"node_modules"

src/Microsoft.AspNetCore.NodeServices.Sockets/SocketNodeInstance.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,15 @@ protected override async Task<T> InvokeExportAsync<T>(NodeInvocationInfo invocat
6262
{
6363
if (_connectionHasFailed)
6464
{
65+
// _connectionHasFailed implies a protocol-level error. The old instance is no longer of any use.
66+
var allowConnectionDraining = false;
67+
6568
// This special exception type forces NodeServicesImpl to restart the Node instance
6669
throw new NodeInvocationException(
6770
"The SocketNodeInstance socket connection failed. See logs to identify the reason.",
68-
null,
69-
nodeInstanceUnavailable: true);
71+
details: null,
72+
nodeInstanceUnavailable: true,
73+
allowConnectionDraining: allowConnectionDraining);
7074
}
7175

7276
if (_virtualConnectionClient == null)

src/Microsoft.AspNetCore.NodeServices/HostingModels/NodeInvocationException.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ public class NodeInvocationException : Exception
1313
/// </summary>
1414
public bool NodeInstanceUnavailable { get; private set; }
1515

16+
/// <summary>
17+
/// If true, indicates that even though the invocation failed because the Node.js instance could not be reached
18+
/// or needs to be restarted, that Node.js instance may remain alive for a period in order to complete any
19+
/// outstanding requests.
20+
/// </summary>
21+
public bool AllowConnectionDraining { get; private set;}
22+
1623
/// <summary>
1724
/// Creates a new instance of <see cref="NodeInvocationException"/>.
1825
/// </summary>
@@ -29,10 +36,20 @@ public NodeInvocationException(string message, string details)
2936
/// <param name="message">A description of the exception.</param>
3037
/// <param name="details">Additional information, such as a Node.js stack trace, representing the exception.</param>
3138
/// <param name="nodeInstanceUnavailable">Specifies a value for the <see cref="NodeInstanceUnavailable"/> flag.</param>
32-
public NodeInvocationException(string message, string details, bool nodeInstanceUnavailable)
39+
/// <param name="allowConnectionDraining">Specifies a value for the <see cref="AllowConnectionDraining"/> flag.</param>
40+
public NodeInvocationException(string message, string details, bool nodeInstanceUnavailable, bool allowConnectionDraining)
3341
: this(message, details)
3442
{
43+
// Reject a meaningless combination of flags
44+
if (allowConnectionDraining && !nodeInstanceUnavailable)
45+
{
46+
throw new ArgumentException(
47+
$"The '${ nameof(allowConnectionDraining) }' parameter cannot be true " +
48+
$"unless the '${ nameof(nodeInstanceUnavailable) }' parameter is also true.");
49+
}
50+
3551
NodeInstanceUnavailable = nodeInstanceUnavailable;
52+
AllowConnectionDraining = allowConnectionDraining;
3653
}
3754
}
3855
}

src/Microsoft.AspNetCore.NodeServices/HostingModels/OutOfProcessNodeInstance.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ npm install -g node-inspector
4242
private readonly StringAsTempFile _entryPointScript;
4343
private FileSystemWatcher _fileSystemWatcher;
4444
private int _invocationTimeoutMilliseconds;
45+
private bool _launchWithDebugging;
4546
private readonly Process _nodeProcess;
4647
private int? _nodeDebuggingPort;
4748
private bool _nodeProcessNeedsRestart;
@@ -78,9 +79,10 @@ public OutOfProcessNodeInstance(
7879
OutputLogger = nodeOutputLogger;
7980
_entryPointScript = new StringAsTempFile(entryPointScript);
8081
_invocationTimeoutMilliseconds = invocationTimeoutMilliseconds;
82+
_launchWithDebugging = launchWithDebugging;
8183

8284
var startInfo = PrepareNodeProcessStartInfo(_entryPointScript.FileName, projectPath, commandLineArguments,
83-
environmentVars, launchWithDebugging, debuggingPort);
85+
environmentVars, _launchWithDebugging, debuggingPort);
8486
_nodeProcess = LaunchNodeProcess(startInfo);
8587
_watchFileExtensions = watchFileExtensions;
8688
_fileSystemWatcher = BeginFileWatcher(projectPath);
@@ -103,10 +105,17 @@ public async Task<T> InvokeExportAsync<T>(
103105
{
104106
// This special kind of exception triggers a transparent retry - NodeServicesImpl will launch
105107
// a new Node instance and pass the invocation to that one instead.
108+
// Note that if the Node process is listening for debugger connections, then we need it to shut
109+
// down immediately and not stay open for connection draining (because if it did, the new Node
110+
// instance wouldn't able to start, because the old one would still hold the debugging port).
106111
var message = _nodeProcess.HasExited
107112
? "The Node process has exited"
108113
: "The Node process needs to restart";
109-
throw new NodeInvocationException(message, null, nodeInstanceUnavailable: true);
114+
throw new NodeInvocationException(
115+
message,
116+
details: null,
117+
nodeInstanceUnavailable: true,
118+
allowConnectionDraining: !_launchWithDebugging);
110119
}
111120

112121
// Construct a new cancellation token that combines the supplied token with the configured invocation

src/Microsoft.AspNetCore.NodeServices/NodeServicesImpl.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ private async Task<T> InvokeExportWithPossibleRetryAsync<T>(string moduleName, s
7272
{
7373
if (_currentNodeInstance == nodeInstance)
7474
{
75-
DisposeNodeInstance(_currentNodeInstance, delay: ConnectionDrainingTimespan);
75+
var disposalDelay = ex.AllowConnectionDraining ? ConnectionDrainingTimespan : TimeSpan.Zero;
76+
DisposeNodeInstance(_currentNodeInstance, disposalDelay);
7677
_currentNodeInstance = null;
7778
}
7879
}

src/Microsoft.AspNetCore.NodeServices/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"description": "Invoke Node.js modules at runtime in ASP.NET Core applications.",
3-
"version": "1.1.0-beta2-*",
3+
"version": "1.1.0-rc2-*",
44
"packOptions": {
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)