Skip to content

Commit

Permalink
rename to trackServerFetches
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich Harris committed May 17, 2023
1 parent 49a6d81 commit 487aa22
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/kit/src/core/config/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const get_defaults = (prefix = '') => ({
checkOrigin: true
},
dangerZone: {
trackServerFetchesPotentiallyExposingSecrets: false
trackServerFetches: false
},
embedded: false,
env: {
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/core/config/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const options = object(

dangerZone: object({
// TODO 2.0: Remove this
trackServerFetchesPotentiallyExposingSecrets: boolean(false)
trackServerFetches: boolean(false)
}),

embedded: boolean(false),
Expand Down
4 changes: 1 addition & 3 deletions packages/kit/src/core/sync/write_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ export const options = {
app_template_contains_nonce: ${template.includes('%sveltekit.nonce%')},
csp: ${s(config.kit.csp)},
csrf_check_origin: ${s(config.kit.csrf.checkOrigin)},
track_server_fetches_potentially_exposing_secrets: ${s(
config.kit.dangerZone.trackServerFetchesPotentiallyExposingSecrets
)},
track_server_fetches: ${s(config.kit.dangerZone.trackServerFetches)},
embedded: ${config.kit.embedded},
env_public_prefix: '${config.kit.env.publicPrefix}',
hooks: null, // added lazily, via \`get_hooks\`
Expand Down
3 changes: 1 addition & 2 deletions packages/kit/src/runtime/server/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ export async function render_data(
}
return data;
},
track_server_fetches_potentially_exposing_secrets:
options.track_server_fetches_potentially_exposing_secrets
track_server_fetches: options.track_server_fetches
});
} catch (e) {
aborted = true;
Expand Down
3 changes: 1 addition & 2 deletions packages/kit/src/runtime/server/page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ export async function render_page(event, page, options, manifest, state, resolve
}
return data;
},
track_server_fetches_potentially_exposing_secrets:
options.track_server_fetches_potentially_exposing_secrets
track_server_fetches: options.track_server_fetches
});
} catch (e) {
load_error = /** @type {Error} */ (e);
Expand Down
6 changes: 3 additions & 3 deletions packages/kit/src/runtime/server/page/load_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { validate_depends } from '../../shared.js';
* state: import('types').SSRState;
* node: import('types').SSRNode | undefined;
* parent: () => Promise<Record<string, any>>;
* track_server_fetches_potentially_exposing_secrets: boolean;
* track_server_fetches: boolean;
* }} opts
* @returns {Promise<import('types').ServerDataNode | null>}
*/
Expand All @@ -20,7 +20,7 @@ export async function load_server_data({
node,
parent,
// TODO 2.0: Remove this
track_server_fetches_potentially_exposing_secrets
track_server_fetches
}) {
if (!node?.server) return null;

Expand Down Expand Up @@ -60,7 +60,7 @@ export async function load_server_data({
}

// TODO 2.0: Remove this
if (track_server_fetches_potentially_exposing_secrets) {
if (track_server_fetches) {
uses.dependencies.add(url.href);
}

Expand Down
3 changes: 1 addition & 2 deletions packages/kit/src/runtime/server/page/respond_with_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ export async function respond_with_error({
state,
node: default_layout,
parent: async () => ({}),
track_server_fetches_potentially_exposing_secrets:
options.track_server_fetches_potentially_exposing_secrets
track_server_fetches: options.track_server_fetches
});

const server_data = await server_data_promise;
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/test/apps/basics/test/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ test.describe('Invalidation', () => {
});

test('fetch in server load cannot be invalidated', async ({ page, app, request }) => {
// TODO 2.0: Can remove this test after `dangerZone.trackServerFetchesPotentiallyExposingSecrets` and associated code is removed
// TODO 2.0: Can remove this test after `dangerZone.trackServerFetches` and associated code is removed
await request.get('/load/invalidation/server-fetch/count.json?reset');
await page.goto('/load/invalidation/server-fetch');
const selector = '[data-testid="count"]';
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/test/apps/options/svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const config = {
}
},
dangerZone: {
trackServerFetchesPotentiallyExposingSecrets: true
trackServerFetches: true
},
files: {
assets: 'public',
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/test/apps/options/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ test.describe('Routing', () => {

test.describe('load', () => {
// TODO 2.0: Remove this test
test('fetch in server load can be invalidated when `dangerZone.trackServerFetchesPotentiallyExposingSecrets` is set', async ({
test('fetch in server load can be invalidated when `dangerZone.trackServerFetches` is set', async ({
page,
app,
request,
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export interface KitConfig {
* Automatically add server-side `fetch`ed URLs to the `dependencies` map of `load` functions. This will expose secrets
* to the client if your URL contains them.
*/
trackServerFetchesPotentiallyExposingSecrets?: boolean;
trackServerFetches?: boolean;
};
/**
* Whether or not the app is embedded inside a larger app. If `true`, SvelteKit will add its event listeners related to navigation etc on the parent of `%sveltekit.body%` instead of `window`, and will pass `params` from the server rather than inferring them from `location.pathname`.
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/types/internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export interface SSROptions {
app_template_contains_nonce: boolean;
csp: ValidatedConfig['kit']['csp'];
csrf_check_origin: boolean;
track_server_fetches_potentially_exposing_secrets: boolean;
track_server_fetches: boolean;
embedded: boolean;
env_public_prefix: string;
hooks: ServerHooks;
Expand Down

0 comments on commit 487aa22

Please sign in to comment.