Skip to content

minor tidy up #855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 3, 2021
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
2 changes: 1 addition & 1 deletion packages/kit/src/runtime/server/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createHash } from 'crypto';
import render_page from './page.js';
import render_page from './page/index.js';
import render_endpoint from './endpoint.js';

/** @param {string} body */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import devalue from 'devalue';
import fetch, { Response } from 'node-fetch';
import { writable } from 'svelte/store';
import { parse, resolve, URLSearchParams } from 'url';
import { normalize } from '../load.js';
import { ssr } from './index.js';
import { normalize } from '../../load.js';
import { ssr } from '../index.js';

const s = JSON.stringify;

Expand All @@ -18,7 +18,7 @@ const s = JSON.stringify;
* }} opts
* @returns {Promise<import('types').Response>}
*/
async function get_response({ request, options, $session, route, status = 200, error }) {
async function respond({ request, options, $session, route, status = 200, error }) {
const serialized_session = try_serialize($session, (error) => {
throw new Error(`Failed to serialize session data: ${error.message}`);
});
Expand Down Expand Up @@ -220,7 +220,7 @@ async function get_response({ request, options, $session, route, status = 200, e
? { ssr: options.ssr, router: options.router, hydrate: options.hydrate }
: await component_promises[component_promises.length - 1];
} catch (e) {
return await get_response({
return await respond({
request,
options,
$session,
Expand Down Expand Up @@ -267,12 +267,6 @@ async function get_response({ request, options, $session, route, status = 200, e
const mod = await component_promises[i];
components[i] = mod.default;

if (mod.preload) {
throw new Error(
'preload has been deprecated in favour of load. Please consult the documentation: https://kit.svelte.dev/docs#loading'
);
}

if (mod.load) {
loaded = await mod.load.call(null, {
page,
Expand Down Expand Up @@ -303,7 +297,7 @@ async function get_response({ request, options, $session, route, status = 200, e
// TODO there's some logic that's duplicated in the client runtime,
// it would be nice to DRY it out if possible
if (loaded.error) {
return await get_response({
return await respond({
request,
options,
$session,
Expand Down Expand Up @@ -375,17 +369,17 @@ async function get_response({ request, options, $session, route, status = 200, e
} catch (e) {
if (error) throw e instanceof Error ? e : new Error(e);

return await get_response({
return await respond({
request,
options,
$session,
route: null,
status: 500,
error: e instanceof Error ? e : { name: 'Error', message: e.toString() }
});
} finally {
unsubscribe();
}

unsubscribe();
} else {
rendered = {
head: '',
Expand Down Expand Up @@ -499,7 +493,7 @@ export default async function render_page(request, route, options) {

const $session = await options.hooks.getSession({ context: request.context });

const response = await get_response({
const response = await respond({
request,
options,
$session,
Expand Down
15 changes: 0 additions & 15 deletions packages/kit/test/apps/basics/src/routes/preload/__tests__.js

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 3 additions & 0 deletions packages/kit/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ async function setup({ port }) {
nojs: await browser.newContext({ javaScriptEnabled: false })
};

contexts.js.setDefaultTimeout(5000);
contexts.nojs.setDefaultTimeout(5000);

const cookie = {
name: 'name',
value: 'SvelteKit',
Expand Down