0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

[ci] format

This commit is contained in:
Matthew Phillips 2023-12-14 13:40:07 +00:00 committed by astrobot-houston
parent e1a5a2d36a
commit d2340058aa
3 changed files with 16 additions and 8 deletions

View file

@ -1299,5 +1299,5 @@ export const UnhandledRejection = {
message: (stack: string) => {
return `Astro detected an unhandled rejection. Here's the stack trace:\n${stack}`;
},
hint: 'Make sure your promises all have an `await` or a `.catch()` handler.'
}
hint: 'Make sure your promises all have an `await` or a `.catch()` handler.',
};

View file

@ -1,4 +1,4 @@
import type { ModuleLoader } from '../core/module-loader/index.js'
import type { ModuleLoader } from '../core/module-loader/index.js';
import type { AstroConfig } from '../@types/astro.js';
import type DevPipeline from './devPipeline.js';
@ -7,7 +7,12 @@ import { createSafeError } from '../core/errors/index.js';
import { formatErrorMessage } from '../core/messages.js';
import { eventError, telemetry } from '../events/index.js';
export function recordServerError(loader: ModuleLoader, config: AstroConfig, pipeline: DevPipeline, _err: unknown) {
export function recordServerError(
loader: ModuleLoader,
config: AstroConfig,
pipeline: DevPipeline,
_err: unknown
) {
const err = createSafeError(_err);
// This could be a runtime error from Vite's SSR module, so try to fix it here
@ -28,6 +33,6 @@ export function recordServerError(loader: ModuleLoader, config: AstroConfig, pip
return {
error: err,
errorWithMetadata
errorWithMetadata,
};
}

View file

@ -53,15 +53,18 @@ export default function createVitePluginAstroServer({
function handleUnhandledRejection(rejection: any) {
const error = new AstroError({
...AstroErrorData.UnhandledRejection,
message: AstroErrorData.UnhandledRejection.message(rejection?.stack || rejection)
message: AstroErrorData.UnhandledRejection.message(rejection?.stack || rejection),
});
const store = localStorage.getStore();
if(store instanceof IncomingMessage) {
if (store instanceof IncomingMessage) {
const request = store;
setRouteError(controller.state, request.url!, error);
}
const { errorWithMetadata } = recordServerError(loader, settings.config, pipeline, error);
setTimeout(async () => loader.webSocketSend(await getViteErrorPayload(errorWithMetadata)), 200)
setTimeout(
async () => loader.webSocketSend(await getViteErrorPayload(errorWithMetadata)),
200
);
}
process.on('unhandledRejection', handleUnhandledRejection);