Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/angular/build/src/builders/dev-server/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import { normalizeCacheOptions } from '../../utils/normalize-cache';
import { ApplicationBuilderOptions } from '../application';
import { Schema as DevServerOptions } from './schema';

export type NormalizedDevServerOptions = Awaited<ReturnType<typeof normalizeOptions>>;
export type NormalizedDevServerOptions = Omit<
Awaited<ReturnType<typeof normalizeOptions>>,
'strictPort'
> & {
strictPort?: boolean;
};

/**
* Normalize the user provided options by creating full paths for all path based options
Expand Down Expand Up @@ -122,6 +127,7 @@ export async function normalizeOptions(
buildTarget,
host: host ?? 'localhost',
port,
strictPort: port !== 0,
poll,
open,
verbose,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ describeServeBuilder(executeDevServer, DEV_SERVER_BUILDER_INFO, (harness, setupT
expectNoLog(logs, 'Unexpected character "EOF"');
},
],
{ outputLogsOnFailure: false },
{ outputLogsOnFailure: false, timeout: 60_000 },
);
});
}, 90_000);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async function createServerConfig(
ssrFiles,
},
port: serverOptions.port,
strictPort: true,
strictPort: serverOptions.strictPort ?? true,
host: serverOptions.host,
open: serverOptions.open,
allowedHosts: serverOptions.allowedHosts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,33 @@ async function createProxy(target: string, secure: boolean, ws = true): Promise<
},
}).listen(proxyPort);

server.on('error', () => {
// Ignore proxy connection errors that occur when the browser reloads or disconnects.
});

return {
server,
url: `${secure ? 'https' : 'http'}://localhost:${proxyPort}`,
};
}

async function waitForAppLiveReload(page: Page): Promise<void> {
const startTime = Date.now();
while (Date.now() - startTime < 30_000) {
try {
const text = await page.evaluate(() => document.querySelector('p')?.innerText);
if (text === 'app-live-reload') {
return;
}
} catch {
// Ignore execution context destruction errors during page navigation.
}
await setTimeoutPromise(100);
}

throw new Error('Timed out waiting for page to reload with updated text.');
}

async function goToPageAndWaitForWS(page: Page, url: string): Promise<void> {
const baseUrl = url.replace(/^http/, 'ws');
const socksRequest = baseUrl.at(-1) === '/' ? `${baseUrl}ng-cli-ws` : `${baseUrl}/ng-cli-ws`;
Expand Down Expand Up @@ -203,8 +224,7 @@ describeServeBuilder(
async ({ result }) => {
expect(result?.success).toBeTrue();

// Wait for page to reload.
await setTimeoutPromise(500);
await waitForAppLiveReload(page);

const innerText = await page.evaluate(() => document.querySelector('p').innerText);
expect(innerText).toBe('app-live-reload');
Expand Down Expand Up @@ -238,8 +258,7 @@ describeServeBuilder(
async ({ result }) => {
expect(result?.success).toBeTrue();

// Wait for page to reload.
await setTimeoutPromise(500);
await waitForAppLiveReload(page);

const innerText = await page.evaluate(
() => document.querySelector('p').innerText,
Expand Down Expand Up @@ -281,8 +300,7 @@ describeServeBuilder(
async ({ result }) => {
expect(result?.success).toBeTrue();

// Wait for page to reload.
await setTimeoutPromise(500);
await waitForAppLiveReload(page);

const innerText = await page.evaluate(
() => document.querySelector('p').innerText,
Expand Down