kit: [hooks] `sequence` helper function doesn't account for `preload`

Describe the bug

The sequence helper funciton doesn’t seem to call the preload function specified in handle hooks.

Reproduction

Reproduction on StackBlitz

Please find the hooks.server.js file as such:

import { sequence } from '@sveltejs/kit/hooks';

const preloadFonts = async ({ event, resolve }) =>
	await resolve(event, {
		preload: ({ type, path }) => {
			if (type === 'font') {
				console.log(type, path);
				return true;
			}
			return false;
		}
	});

export const handle = sequence(preloadFonts);

// export const handle = preloadFonts;

Run npm run build.

The following log output is seen when handle is set to preloadFonts, but not when it is set to sequence(preloadFonts).

Logs

vite v4.0.0 building SSR bundle for production...
✓ 63 modules transformed.
6:51:28 PM [vite-plugin-svelte] ssr compile done.
package                 files    time      avg
kit-template-default        7   0.14s   20.1ms
.svelte-kit/output/server/vite-manifest.json                    2.71 kB
.svelte-kit/output/server/entries/pages/_page.js                0.05 kB
.svelte-kit/output/server/entries/pages/about/_page.js          0.09 kB
.svelte-kit/output/server/chunks/hooks.server.js                0.27 kB
.svelte-kit/output/server/entries/fallbacks/error.svelte.js     0.62 kB
.svelte-kit/output/server/entries/pages/about/_page.svelte.js   0.93 kB
.svelte-kit/output/server/chunks/stores.js                      1.02 kB
.svelte-kit/output/server/chunks/index2.js                      1.32 kB
.svelte-kit/output/server/chunks/index.js                       4.15 kB
.svelte-kit/output/server/entries/pages/_layout.svelte.js       4.40 kB
.svelte-kit/output/server/entries/pages/_page.svelte.js         7.45 kB
.svelte-kit/output/server/index.js                             80.79 kB
font ./_app/immutable/assets/fira-mono-cyrillic-ext-400-normal-3df7909e.woff2
font ./_app/immutable/assets/fira-mono-all-400-normal-1e3b098c.woff
font ./_app/immutable/assets/fira-mono-cyrillic-400-normal-c7d433fd.woff2
font ./_app/immutable/assets/fira-mono-greek-ext-400-normal-9e2fe623.woff2
font ./_app/immutable/assets/fira-mono-greek-400-normal-a8be01ce.woff2
font ./_app/immutable/assets/fira-mono-latin-ext-400-normal-6bfabd30.woff2
font ./_app/immutable/assets/fira-mono-latin-400-normal-e43b3538.woff2
font ./_app/immutable/assets/fira-mono-cyrillic-ext-400-normal-3df7909e.woff2
font ./_app/immutable/assets/fira-mono-all-400-normal-1e3b098c.woff
font ./_app/immutable/assets/fira-mono-cyrillic-400-normal-c7d433fd.woff2
font ./_app/immutable/assets/fira-mono-greek-ext-400-normal-9e2fe623.woff2
font ./_app/immutable/assets/fira-mono-greek-400-normal-a8be01ce.woff2
font ./_app/immutable/assets/fira-mono-latin-ext-400-normal-6bfabd30.woff2
font ./_app/immutable/assets/fira-mono-latin-400-normal-e43b3538.woff2

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.90 
    @sveltejs/kit: next => 1.0.0-next.579 
    svelte: ^3.54.0 => 3.54.0 
    vite: ^4.0.0 => 4.0.0

Severity

annoyance

Additional Information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 19 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Hi, any progress with this issue? I am using Supabase SvelteKit Auth helpers and they also warn us regarding this issue with filterSerializedResponseHeaders not working when using sequence.

I have a similar issue, also using Auth.js: #7027 (reply in thread)

I’m having exact same issue and I can’t find a workaround for this.

Wow! This is weird.

Locally, when I do npm run build and npm run preview I do NOT see any console.log’s in my preload, and I do NOT see my font files being preloaded.

But when deployed on Vercel I DO see my font files preloaded (did not go through the trouble of deploying those console.log statements, and then digging up Vercel’s logs).

@Rich-Harris are asset preloads handled differently by default on Vercel, vs a non-Vercel running of a prod build? I can’t imagine that they would, but somehow that’s what I’m seeing