[ci] format

This commit is contained in:
matthewp 2023-03-31 19:29:49 +00:00 committed by fredkbot
parent d54cbe4134
commit 9846b3e935
7 changed files with 17 additions and 8 deletions

View file

@ -202,7 +202,7 @@ export class App {
}); });
const response = await renderPage(mod, ctx, this.#env); const response = await renderPage(mod, ctx, this.#env);
Reflect.set(request, responseSentSymbol, true) Reflect.set(request, responseSentSymbol, true);
return response; return response;
} catch (err: any) { } catch (err: any) {
error(this.#logging, 'ssr', err.stack || err.message || String(err)); error(this.#logging, 'ssr', err.stack || err.message || String(err));

View file

@ -163,7 +163,7 @@ class AstroCookies implements AstroCookiesInterface {
true, true,
]); ]);
if((this.#request as any)[responseSentSymbol]) { if ((this.#request as any)[responseSentSymbol]) {
throw new AstroError({ throw new AstroError({
...AstroErrorData.ResponseSentError, ...AstroErrorData.ResponseSentError,
}); });

View file

@ -199,7 +199,7 @@ export function createResult(args: CreateResultArgs): SSRResult {
redirect: args.ssr redirect: args.ssr
? (path, status) => { ? (path, status) => {
// If the response is already sent, error as we cannot proceed with the redirect. // If the response is already sent, error as we cannot proceed with the redirect.
if((request as any)[responseSentSymbol]) { if ((request as any)[responseSentSymbol]) {
throw new AstroError({ throw new AstroError({
...AstroErrorData.ResponseSentError, ...AstroErrorData.ResponseSentError,
}); });

View file

@ -20,7 +20,10 @@ export const decoder = new TextDecoder();
// Rendering produces either marked strings of HTML or instructions for hydration. // Rendering produces either marked strings of HTML or instructions for hydration.
// These directive instructions bubble all the way up to renderPage so that we // These directive instructions bubble all the way up to renderPage so that we
// can ensure they are added only once, and as soon as possible. // can ensure they are added only once, and as soon as possible.
export function stringifyChunk(result: SSRResult, chunk: string | SlotString | RenderInstruction): string { export function stringifyChunk(
result: SSRResult,
chunk: string | SlotString | RenderInstruction
): string {
if (typeof (chunk as any).type === 'string') { if (typeof (chunk as any).type === 'string') {
const instruction = chunk as RenderInstruction; const instruction = chunk as RenderInstruction;
switch (instruction.type) { switch (instruction.type) {

View file

@ -99,7 +99,11 @@ export async function writeWebResponse(res: http.ServerResponse, webResponse: Re
res.end(); res.end();
} }
export async function writeSSRResult(webRequest: Request, webResponse: Response, res: http.ServerResponse) { export async function writeSSRResult(
webRequest: Request,
webResponse: Response,
res: http.ServerResponse
) {
Reflect.set(webRequest, Symbol.for('astro.responseSent'), true); Reflect.set(webRequest, Symbol.for('astro.responseSent'), true);
return writeWebResponse(res, webResponse); return writeWebResponse(res, webResponse);
} }

View file

@ -30,8 +30,10 @@ describe('Astro.redirect', () => {
try { try {
const text = await response.text(); const text = await response.text();
expect(false).to.equal(true); expect(false).to.equal(true);
} catch(e) { } catch (e) {
expect(e.message).to.equal('The response has already been sent to the browser and cannot be altered.'); expect(e.message).to.equal(
'The response has already been sent to the browser and cannot be altered.'
);
} }
}); });
}); });

View file

@ -13,7 +13,7 @@ describe('astro/src/core/cookies', () => {
try { try {
cookies.set('foo', 'bar'); cookies.set('foo', 'bar');
expect(false).to.equal(true); expect(false).to.equal(true);
} catch(err) { } catch (err) {
expect(err.errorCode).to.equal(3030); expect(err.errorCode).to.equal(3030);
} }
}); });