diff --git a/packages/astro/src/core/dev/index.ts b/packages/astro/src/core/dev/index.ts index a128fa1ecd..b45c4491aa 100644 --- a/packages/astro/src/core/dev/index.ts +++ b/packages/astro/src/core/dev/index.ts @@ -151,7 +151,6 @@ export class AstroDevServer { info(this.logging, 'astro', msg.devHost({ host: `http://${this.hostname}:${this.port}` })); resolve(); }); - this.httpServer?.on('error', onError); }; const onError = (err: NodeJS.ErrnoException) => { @@ -170,6 +169,7 @@ export class AstroDevServer { }; listen(); + this.httpServer?.on('error', onError); }); } diff --git a/packages/astro/src/runtime/server/index.ts b/packages/astro/src/runtime/server/index.ts index 7a41ef7ab0..6e56a336e6 100644 --- a/packages/astro/src/runtime/server/index.ts +++ b/packages/astro/src/runtime/server/index.ts @@ -365,13 +365,17 @@ export async function renderToString(result: SSRResult, componentFactory: AstroC const uniqueElements = (item: any, index: number, all: any[]) => { const props = JSON.stringify(item.props); const children = item.children; - return index === all.findIndex(i => JSON.stringify(i.props) === props && i.children == children) -} + return index === all.findIndex((i) => JSON.stringify(i.props) === props && i.children == children); +}; export async function renderPage(result: SSRResult, Component: AstroComponentFactory, props: any, children: any) { const template = await renderToString(result, Component, props, children); - const styles = Array.from(result.styles).filter(uniqueElements).map((style) => renderElement('style', style)); - const scripts = Array.from(result.scripts).filter(uniqueElements).map((script) => renderElement('script', script)); + const styles = Array.from(result.styles) + .filter(uniqueElements) + .map((style) => renderElement('style', style)); + const scripts = Array.from(result.scripts) + .filter(uniqueElements) + .map((script) => renderElement('script', script)); return template.replace('', styles.join('\n') + scripts.join('\n') + ''); }