Skip to content

Commit 96cc344

Browse files
committed
Sanitize server stack trace on errors
1 parent 8692d98 commit 96cc344

File tree

37 files changed

+157
-260
lines changed

37 files changed

+157
-260
lines changed

.changeset/sharp-experts-unite.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/twenty-pants-fetch.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ jobs:
7474
- run: pnpm playwright install ${{ matrix.e2e-browser }}
7575
- run: pnpm run sync-all
7676
- run: pnpm test:kit
77-
env:
78-
NODE_OPTIONS: ${{matrix.node-version == 22 && '--experimental-strip-types' || ''}} # allows loading svelte.config.ts
7977
- name: Print flaky test report
8078
run: node scripts/print-flaky-test-report.js
8179
- name: Archive test results
@@ -183,19 +181,14 @@ jobs:
183181
path: test-results-server-side-route-resolution-${{ matrix.mode }}.tar.gz
184182
test-others:
185183
runs-on: ubuntu-latest
186-
strategy:
187-
matrix:
188-
node-version: [18, 20, 22, 24]
189184
steps:
190185
- uses: actions/checkout@v4
191186
- uses: pnpm/[email protected]
192187
- uses: actions/setup-node@v4
193188
with:
194-
node-version: ${{matrix.node-version}}
189+
node-version: 18
195190
cache: pnpm
196191
- run: pnpm install --frozen-lockfile
197192
- run: pnpm playwright install chromium
198193
- run: cd packages/kit && pnpm prepublishOnly
199194
- run: pnpm run test:others
200-
env:
201-
NODE_OPTIONS: ${{matrix.node-version == 22 && '--experimental-strip-types' || ''}} # allows loading svelte.config.ts

eslint.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ export default [
1414
'**/test-results',
1515
'**/build',
1616
'**/.custom-out-dir',
17-
'packages/adapter-*/files',
18-
'packages/kit/src/core/config/fixtures/multiple', // dir contains svelte config with multiple extensions tripping eslint
19-
'packages/package/test/fixtures/typescript-svelte-config/expected'
17+
'packages/adapter-*/files'
2018
]
2119
},
2220
{

packages/kit/src/cli.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import fs from 'node:fs';
2+
import path from 'node:path';
23
import process from 'node:process';
34
import colors from 'kleur';
45
import sade from 'sade';
@@ -27,11 +28,8 @@ prog
2728
.describe('Synchronise generated type definitions')
2829
.option('--mode', 'Specify a mode for loading environment variables', 'development')
2930
.action(async ({ mode }) => {
30-
const config_files = ['js', 'ts']
31-
.map((ext) => `svelte.config.${ext}`)
32-
.filter((f) => fs.existsSync(f));
33-
if (config_files.length === 0) {
34-
console.warn(`Missing Svelte config file in ${process.cwd()} — skipping`);
31+
if (!fs.existsSync('svelte.config.js')) {
32+
console.warn(`Missing ${path.resolve('svelte.config.js')} — skipping`);
3533
return;
3634
}
3735

packages/kit/src/core/config/fixtures/multiple/svelte.config.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/kit/src/core/config/fixtures/multiple/svelte.config.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/kit/src/core/config/fixtures/typescript/svelte.config.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/kit/src/core/config/index.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,17 @@ export function load_error_page(config) {
5757
}
5858

5959
/**
60-
* Loads and validates Svelte config file
60+
* Loads and validates svelte.config.js
6161
* @param {{ cwd?: string }} options
6262
* @returns {Promise<import('types').ValidatedConfig>}
6363
*/
6464
export async function load_config({ cwd = process.cwd() } = {}) {
65-
const config_files = ['js', 'ts']
66-
.map((ext) => path.join(cwd, `svelte.config.${ext}`))
67-
.filter((f) => fs.existsSync(f));
65+
const config_file = path.join(cwd, 'svelte.config.js');
6866

69-
if (config_files.length === 0) {
67+
if (!fs.existsSync(config_file)) {
7068
return process_config({}, { cwd });
7169
}
72-
const config_file = config_files[0];
73-
if (config_files.length > 1) {
74-
console.log(
75-
`Found multiple Svelte config files in ${cwd}: ${config_files.map((f) => path.basename(f)).join(', ')}. Using ${path.basename(config_file)}`
76-
);
77-
}
70+
7871
const config = await import(`${url.pathToFileURL(config_file).href}?ts=${Date.now()}`);
7972

8073
try {
@@ -83,7 +76,7 @@ export async function load_config({ cwd = process.cwd() } = {}) {
8376
const error = /** @type {Error} */ (e);
8477

8578
// redact the stack trace — it's not helpful to users
86-
error.stack = `Could not load ${config_file}: ${error.message}\n`;
79+
error.stack = `Could not load svelte.config.js: ${error.message}\n`;
8780
throw error;
8881
}
8982
}
@@ -118,7 +111,7 @@ function process_config(config, { cwd = process.cwd() } = {}) {
118111
export function validate_config(config) {
119112
if (typeof config !== 'object') {
120113
throw new Error(
121-
'The Svelte config file must have a configuration object as its default export. See https://svelte.dev/docs/kit/configuration'
114+
'svelte.config.js must have a configuration object as its default export. See https://svelte.dev/docs/kit/configuration'
122115
);
123116
}
124117

packages/kit/src/core/config/index.spec.js

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -365,30 +365,6 @@ test('load default config (esm)', async () => {
365365
expect(config).toEqual(defaults);
366366
});
367367

368-
test('load default config (esm) with .ts extensions', async () => {
369-
const cwd = join(__dirname, 'fixtures/typescript');
370-
371-
const config = await load_config({ cwd });
372-
remove_keys(config, ([, v]) => typeof v === 'function');
373-
374-
const defaults = get_defaults(cwd + '/');
375-
defaults.kit.version.name = config.kit.version.name;
376-
377-
expect(config).toEqual(defaults);
378-
});
379-
380-
test('load .js config when both .js and .ts configs are present', async () => {
381-
const cwd = join(__dirname, 'fixtures/multiple');
382-
383-
const config = await load_config({ cwd });
384-
remove_keys(config, ([, v]) => typeof v === 'function');
385-
386-
const defaults = get_defaults(cwd + '/');
387-
defaults.kit.version.name = config.kit.version.name;
388-
389-
expect(config).toEqual(defaults);
390-
});
391-
392368
test('errors on loading config with incorrect default export', async () => {
393369
let message = null;
394370

@@ -401,6 +377,6 @@ test('errors on loading config with incorrect default export', async () => {
401377

402378
assert.equal(
403379
message,
404-
'The Svelte config file must have a configuration object as its default export. See https://svelte.dev/docs/kit/configuration'
380+
'svelte.config.js must have a configuration object as its default export. See https://svelte.dev/docs/kit/configuration'
405381
);
406382
});

0 commit comments

Comments
 (0)