-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Description
Describe the bug
When trying to upload File using the remote function's command() API, the following error message is thrown:
DevalueError: Cannot stringify arbitrary non-POJOs
I wasn't expecting this because devalue is only mentioned in the query section.
This is expected since the page (layout) server load has the same restriction.
However:
- The
formAPI supports file (and even streaming of it) - The
commandAPI does not emphasize the difference from above
I guess I was expecting the command API to use multipart/form-data for the POST request.
Because our form contains a
fileinput, we’ve added anenctype="multipart/form-data"attribute.
I would at prefer a better error message. (e.g. command does not support arbitrary non-POJOs)
Reproduction
<script lang="ts">
import { uploadBinary, uploadString } from './upload.remote';
</script>
<button
type="button"
onclick={async () => {
await uploadBinary({ file: new File([], 'blank.txt') });
}}>Upload Text</button
>
<button
type="button"
onclick={async () => {
await uploadString({ string: 'Hello, World!' });
}}>Upload String</button
>import { command } from '$app/server';
import { file, object, string } from 'valibot';
export const uploadBinary = command(
object({ file: file() }), //
(obj) => console.log(obj)
);
export const uploadString = command(
object({ string: string() }), //
(obj) => console.log(obj)
);Logs
System Info
System:
OS: Windows 11 10.0.26200
CPU: (8) x64 Intel(R) Core(TM) Ultra 7 258V
Memory: 4.37 GB / 31.48 GB
Binaries:
Node: 24.11.0 - C:\Users\hyunb\AppData\Local\fnm_multishells\31224_1764425282727\node.EXE
npm: 11.6.1 - C:\Users\hyunb\AppData\Local\fnm_multishells\31224_1764425282727\npm.CMD
pnpm: 10.23.0 - C:\Users\hyunb\AppData\Local\fnm_multishells\31224_1764425282727\pnpm.CMD
Deno: 2.4.0 - C:\Users\hyunb\.deno\bin\deno.EXE
Browsers:
Chrome: 142.0.7444.176
Edge: Chromium (140.0.3485.54)
Firefox: 145.0.2 - C:\Program Files\Mozilla Firefox\firefox.exe
npmPackages:
@sveltejs/adapter-auto: ^7.0.0 => 7.0.0
@sveltejs/kit: ^2.48.5 => 2.49.0
@sveltejs/vite-plugin-svelte: ^6.2.1 => 6.2.1
svelte: ^5.43.8 => 5.43.15
vite: ^7.2.2 => 7.2.4Severity
annoyance
Additional Information
No response
Metadata
Metadata
Assignees
Labels
No labels