@sveltejs/kit 1.0.0-next.374 → 1.0.0-next.375
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/client/start.js +4 -1
- package/assets/server/index.js +23 -4
- package/dist/cli.js +1 -1
- package/dist/vite.js +9 -2
- package/package.json +1 -1
- package/types/internal.d.ts +5 -1
package/assets/client/start.js
CHANGED
|
@@ -44,7 +44,10 @@ function normalize(loaded) {
|
|
|
44
44
|
const status = loaded.status;
|
|
45
45
|
|
|
46
46
|
if (!loaded.error && has_error_status) {
|
|
47
|
-
return {
|
|
47
|
+
return {
|
|
48
|
+
status: status || 500,
|
|
49
|
+
error: new Error(`${status}`)
|
|
50
|
+
};
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
const error = typeof loaded.error === 'string' ? new Error(loaded.error) : loaded.error;
|
package/assets/server/index.js
CHANGED
|
@@ -192,6 +192,11 @@ function clone_error(error, get_stack) {
|
|
|
192
192
|
return object;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
/** @type {import('types').SSRErrorPage} */
|
|
196
|
+
const GENERIC_ERROR = {
|
|
197
|
+
id: '__error'
|
|
198
|
+
};
|
|
199
|
+
|
|
195
200
|
/** @param {string} body */
|
|
196
201
|
function error(body) {
|
|
197
202
|
return new Response(body, {
|
|
@@ -2131,7 +2136,10 @@ function normalize(loaded) {
|
|
|
2131
2136
|
const status = loaded.status;
|
|
2132
2137
|
|
|
2133
2138
|
if (!loaded.error && has_error_status) {
|
|
2134
|
-
return {
|
|
2139
|
+
return {
|
|
2140
|
+
status: status || 500,
|
|
2141
|
+
error: new Error(`${status}`)
|
|
2142
|
+
};
|
|
2135
2143
|
}
|
|
2136
2144
|
|
|
2137
2145
|
const error = typeof loaded.error === 'string' ? new Error(loaded.error) : loaded.error;
|
|
@@ -2217,7 +2225,7 @@ function path_matches(path, constraint) {
|
|
|
2217
2225
|
* event: import('types').RequestEvent;
|
|
2218
2226
|
* options: import('types').SSROptions;
|
|
2219
2227
|
* state: import('types').SSRState;
|
|
2220
|
-
* route: import('types').SSRPage |
|
|
2228
|
+
* route: import('types').SSRPage | import('types').SSRErrorPage;
|
|
2221
2229
|
* node: import('types').SSRNode;
|
|
2222
2230
|
* $session: any;
|
|
2223
2231
|
* stuff: Record<string, any>;
|
|
@@ -2799,7 +2807,7 @@ async function respond_with_error({
|
|
|
2799
2807
|
event,
|
|
2800
2808
|
options,
|
|
2801
2809
|
state,
|
|
2802
|
-
route:
|
|
2810
|
+
route: GENERIC_ERROR,
|
|
2803
2811
|
node: default_layout,
|
|
2804
2812
|
$session,
|
|
2805
2813
|
stuff: {},
|
|
@@ -2808,12 +2816,16 @@ async function respond_with_error({
|
|
|
2808
2816
|
})
|
|
2809
2817
|
);
|
|
2810
2818
|
|
|
2819
|
+
if (layout_loaded.loaded.error) {
|
|
2820
|
+
throw layout_loaded.loaded.error;
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2811
2823
|
const error_loaded = /** @type {Loaded} */ (
|
|
2812
2824
|
await load_node({
|
|
2813
2825
|
event,
|
|
2814
2826
|
options,
|
|
2815
2827
|
state,
|
|
2816
|
-
route:
|
|
2828
|
+
route: GENERIC_ERROR,
|
|
2817
2829
|
node: default_error,
|
|
2818
2830
|
$session,
|
|
2819
2831
|
stuff: layout_loaded ? layout_loaded.stuff : {},
|
|
@@ -3458,6 +3470,12 @@ async function respond(request, options, state) {
|
|
|
3458
3470
|
}
|
|
3459
3471
|
}
|
|
3460
3472
|
|
|
3473
|
+
if (state.initiator === GENERIC_ERROR) {
|
|
3474
|
+
return new Response('Internal Server Error', {
|
|
3475
|
+
status: 500
|
|
3476
|
+
});
|
|
3477
|
+
}
|
|
3478
|
+
|
|
3461
3479
|
// if this request came direct from the user, rather than
|
|
3462
3480
|
// via a `fetch` in a `load`, render a 404 page
|
|
3463
3481
|
if (!state.initiator) {
|
|
@@ -3512,6 +3530,7 @@ async function respond(request, options, state) {
|
|
|
3512
3530
|
});
|
|
3513
3531
|
}
|
|
3514
3532
|
|
|
3533
|
+
// TODO is this necessary? should we just return a plain 500 at this point?
|
|
3515
3534
|
try {
|
|
3516
3535
|
const $session = await options.hooks.getSession(event);
|
|
3517
3536
|
return await respond_with_error({
|
package/dist/cli.js
CHANGED
package/dist/vite.js
CHANGED
|
@@ -2874,6 +2874,8 @@ function kit() {
|
|
|
2874
2874
|
*/
|
|
2875
2875
|
let paths;
|
|
2876
2876
|
|
|
2877
|
+
let completed_build = false;
|
|
2878
|
+
|
|
2877
2879
|
function vite_client_config() {
|
|
2878
2880
|
/** @type {Record<string, string>} */
|
|
2879
2881
|
const input = {
|
|
@@ -3110,15 +3112,20 @@ function kit() {
|
|
|
3110
3112
|
console.log(
|
|
3111
3113
|
`\nRun ${$.bold().cyan('npm run preview')} to preview your production build locally.`
|
|
3112
3114
|
);
|
|
3115
|
+
|
|
3116
|
+
completed_build = true;
|
|
3113
3117
|
},
|
|
3114
3118
|
|
|
3115
3119
|
/**
|
|
3116
3120
|
* Runs the adapter.
|
|
3117
3121
|
*/
|
|
3118
3122
|
async closeBundle() {
|
|
3119
|
-
if (!
|
|
3120
|
-
|
|
3123
|
+
if (!completed_build) {
|
|
3124
|
+
// vite calls closeBundle when dev-server restarts, ignore that,
|
|
3125
|
+
// and only adapt when build successfully completes.
|
|
3126
|
+
return;
|
|
3121
3127
|
}
|
|
3128
|
+
|
|
3122
3129
|
if (svelte_config.kit.adapter) {
|
|
3123
3130
|
const { adapt } = await import('./chunks/index2.js');
|
|
3124
3131
|
await adapt(svelte_config, build_data, prerendered, { log });
|
package/package.json
CHANGED
package/types/internal.d.ts
CHANGED
|
@@ -290,6 +290,10 @@ export interface SSRPage {
|
|
|
290
290
|
b: Array<number | undefined>;
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
+
export interface SSRErrorPage {
|
|
294
|
+
id: '__error';
|
|
295
|
+
}
|
|
296
|
+
|
|
293
297
|
export interface SSRPagePart {
|
|
294
298
|
id: string;
|
|
295
299
|
load: SSRComponentLoader;
|
|
@@ -300,7 +304,7 @@ export type SSRRoute = SSREndpoint | SSRPage;
|
|
|
300
304
|
export interface SSRState {
|
|
301
305
|
fallback?: string;
|
|
302
306
|
getClientAddress: () => string;
|
|
303
|
-
initiator?: SSRPage |
|
|
307
|
+
initiator?: SSRPage | SSRErrorPage;
|
|
304
308
|
platform?: any;
|
|
305
309
|
prerendering?: PrerenderOptions;
|
|
306
310
|
}
|