sveltejs/kit · error · Error
Promises are not valid remote function arguments
Error message
Promises are not valid remote function arguments
What it means
Remote function arguments are serialized with devalue.stringifyAsync. devalue would silently await promises, turning them into plain resolved values on the other side — which is not what callers expect. SvelteKit therefore explicitly rejects any Promise in the argument graph unless it is an internally generated one (from a File's arrayBuffer()).
Source
Thrown at packages/kit/src/runtime/shared.js:297
name: value.name,
size: value.size,
type: value.type
}));
allowed_promises.add(promise);
return promise;
}
};
// we don't want to allow arbitrary promises, because they won't
// show up as promises on the other side. this is something
// we could potentially change in future. stringifyAsync
// will await them, so we need to explicitly deny them
/** @param {unknown} value */
reducers[remote_promise_guard] = (value) => {
if (value instanceof Promise && !allowed_promises.has(value)) {
throw new Error('Promises are not valid remote function arguments');
}
};
const json = await devalue.stringifyAsync(value, reducers);
return url_friendly_base64_encode(json);
}
/**
* Base64-encodes `string` in such a way that the result is safe to use
* as both a URI component and a filename
* @param {string} string
*/
function url_friendly_base64_encode(string) {
const bytes = text_encoder.encode(string);
// TODO replace with `bytes.toBase64({ alphabet: 'base64url', omitPadding: true })` when we require Node >= 25
return base64_encode(bytes).replaceAll('=', '').replaceAll('+', '-').replaceAll('/', '_');
}View on GitHub (pinned to 03f1687fe6)
Solutions
- Await the promise before passing it: `remoteFn(await someAsync())`
- If you need async data, fetch it inside the remote function itself, not in the caller
- Pass a plain serializable value instead of the promise result's wrapper
- If a Svelte store/derived yields a promise, resolve it before sending (e.g. in an effect or with await)
Example fix
// before
const res = fetch('/api/data');
await updateUser(res);
// after
const res = await fetch('/api/data');
await updateUser(await res.json()); Defensive patterns
Strategy: type-guard
Validate before calling
function assertSerializable(value, seen = new Set()) {
if (value instanceof Promise) throw new Error('Promise passed to remote function — await it first');
if (value && typeof value === 'object' && !seen.has(value)) {
seen.add(value);
Object.values(value).forEach((v) => assertSerializable(v, seen));
}
return value;
} Type guard
const isThenable = (v) => !!v && typeof v === 'object' && typeof v.then === 'function';
Try / catch
try {
await remoteFn(arg);
} catch (e) {
if (e.message === 'Promises are not valid remote function arguments') {
throw new Error('You forgot to await a value before passing it to a remote function');
}
throw e;
} Prevention
- Await async results before passing them to remote functions
- Use TypeScript so passing a Promise where a JSON-serializable type is expected errors at compile time
- Lint rules (no-floating-promises) help catch un-awaited values
- Move async fetching into the remote function itself when possible
When it happens
Trigger: Passing a Promise (or an object/array containing one) as an argument to a remote function, e.g. `remoteFn(fetch('/api/data'))`, `remoteFn(someAsync())`, or a value returned from an async helper that you forgot to await.
Common situations: Forgetting `await` on an async function's result before passing it to a remote `.query()`/`.command()`; passing a fetch() response promise; passing reactive state that wraps a promise (e.g. from an async derived).
Related errors
- Regular expressions are not valid remote function arguments
- Invalid data for Set reviver
- Invalid data for File reviver
- Could not get the request store.
- Cannot export `default` from a remote module (${file}) — ple
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/ff7dbea9e9fd9091.
Report an issue: GitHub.