Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 68c4620

Browse filesBrowse files
Consider React dev server ready when it starts listening, not when (and if) it compiles successfully
1 parent 296435e commit 68c4620
Copy full SHA for 68c4620

File tree

Expand file treeCollapse file tree

1 file changed

+7
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-5
lines changed
Open diff view settings
Collapse file

‎src/Microsoft.AspNetCore.SpaServices.Extensions/ReactDevelopmentServer/ReactDevelopmentServerMiddleware.cs‎

Copy file name to clipboardExpand all lines: src/Microsoft.AspNetCore.SpaServices.Extensions/ReactDevelopmentServer/ReactDevelopmentServerMiddleware.cs
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,16 @@ private static async Task<int> StartCreateReactAppServerAsync(
6666
sourcePath, npmScriptName, null, envVars);
6767
npmScriptRunner.AttachToLogger(logger);
6868

69-
Match openBrowserLine;
7069
using (var stdErrReader = new EventedStreamStringReader(npmScriptRunner.StdErr))
7170
{
7271
try
7372
{
74-
openBrowserLine = await npmScriptRunner.StdOut.WaitForMatch(
75-
new Regex("Local:\\s*(http\\S+)", RegexOptions.None, RegexMatchTimeout),
73+
// Although the React dev server may eventually tell us the URL it's listening on,
74+
// it doesn't do so until it's finished compiling, and even then only if there were
75+
// no compiler warnings. So instead of waiting for that, consider it ready as soon
76+
// as it starts listening for requests.
77+
await npmScriptRunner.StdOut.WaitForMatch(
78+
new Regex("Starting the development server", RegexOptions.None, RegexMatchTimeout),
7679
StartupTimeout);
7780
}
7881
catch (EndOfStreamException ex)
@@ -91,8 +94,7 @@ private static async Task<int> StartCreateReactAppServerAsync(
9194
}
9295
}
9396

94-
var uri = new Uri(openBrowserLine.Groups[1].Value);
95-
return uri.Port;
97+
return portNumber;
9698
}
9799
}
98100
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.