Skip to content

Commit c6215b3

Browse files
committed
Large payloads with dataType: 'json' still didn't work.
1 parent 863e419 commit c6215b3

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ Headlines: Added, Changed, Deprecated, Removed, Fixed, Security
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.8.2] - 2023-04-24
9+
10+
### Fixed
11+
12+
- Large payloads with `dataType: 'json'` still didn't work, fixed now.
13+
814
## [0.8.1] - 2023-04-24
915

1016
### Fixed

src/lib/client/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export type FormOptions<T extends ZodValidation<AnyZodObject>, M> = Partial<{
117117
message: Writable<Validation<UnwrapEffects<T>, M>['message']>;
118118
}) => MaybePromise<unknown | void>);
119119
dataType: 'form' | 'json';
120+
jsonChunkSize: number;
120121
validators:
121122
| false
122123
| Validators<UnwrapEffects<T>>
@@ -1460,7 +1461,7 @@ function formEnhance<T extends AnyZodObject, M>(
14601461
setTimeout(() => validationResponse({ result }), 0);
14611462
} else if (options.dataType === 'json') {
14621463
const postData = get(data);
1463-
const chunks = chunkSubstr(stringify(postData), 500000);
1464+
const chunks = chunkSubstr(stringify(postData), options.jsonChunkSize ?? 500000);
14641465

14651466
for (const chunk of chunks) {
14661467
submit.data.append('__superform_json', chunk);

src/lib/validate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ export async function superValidate<
299299
function tryParseSuperJson(data: FormData) {
300300
if (data.has('__superform_json')) {
301301
try {
302-
const output = parse(data.getAll('__superform_json').join() ?? '');
302+
const output = parse(data.getAll('__superform_json').join('') ?? '');
303303
if (typeof output === 'object') {
304304
return output as Record<string, unknown>;
305305
}

0 commit comments

Comments
 (0)