Skip to content

Commit

Permalink
fix(dev-server): fix dev client requesting build results
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Jul 27, 2020
1 parent 207ce44 commit 91564f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/dev-server/dev-server-client/client-web-socket.ts
Expand Up @@ -7,6 +7,7 @@ export const initClientWebSocket = (win: d.DevClientWindow, config: d.DevClientC
let reconnectAttempts = 0;
let requestBuildResultsTmrId: any;
let hasGottenBuildResults = false;
let buildResultsRequests = 0;

function onOpen(this: WebSocket) {
if (reconnectAttempts > 0) {
Expand All @@ -17,7 +18,8 @@ export const initClientWebSocket = (win: d.DevClientWindow, config: d.DevClientC

if (!hasGottenBuildResults) {
requestBuildResultsTmrId = setInterval(() => {
if (!hasGottenBuildResults && this.readyState === WebSocket.OPEN) {
buildResultsRequests++;
if (!hasGottenBuildResults && this.readyState === WebSocket.OPEN && buildResultsRequests < 500) {
const msg: d.DevServerMessage = {
requestBuildResults: true,
};
Expand Down Expand Up @@ -70,6 +72,7 @@ export const initClientWebSocket = (win: d.DevClientWindow, config: d.DevClientC
// so it's probably best if we do a full page refresh
logReload(`Reconnected to dev server`);
hasGottenBuildResults = true;
buildResultsRequests = 0;
clearInterval(requestBuildResultsTmrId);
win.location.reload(true);
return;
Expand All @@ -89,6 +92,7 @@ export const initClientWebSocket = (win: d.DevClientWindow, config: d.DevClientC
// we just got build results from the server
// let's update our app with the data received
hasGottenBuildResults = true;
buildResultsRequests = 0;
clearInterval(requestBuildResultsTmrId);

emitBuildStatus(win, 'default');
Expand Down
1 change: 1 addition & 0 deletions src/dev-server/index.ts
Expand Up @@ -213,6 +213,7 @@ function emitMessageToClient(serverProcess: ChildProcess, devServerContext: DevS
// a compiler build has finished
// send the build results to the child server process
devServerContext.isActivelyBuilding = false;
devServerContext.lastBuildResults = { ...data };
const msg: DevServerMessage = {
buildResults: { ...data },
};
Expand Down

0 comments on commit 91564f4

Please sign in to comment.