-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: Fields truncated when submitting form using Server Actions #59877
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,6 +117,42 @@ createNextDescribe( | |
: '' | ||
}, 'yes') | ||
}) | ||
|
||
it('should respect the size set in serverActions.bodySizeLimit when submitting form', async function () { | ||
await next.patchFile( | ||
'next.config.js', | ||
` | ||
module.exports = { | ||
experimental: { | ||
serverActions: { bodySizeLimit: '2mb' } | ||
}, | ||
} | ||
` | ||
) | ||
await next.stop() | ||
await next.build() | ||
await next.start() | ||
|
||
const logs: string[] = [] | ||
next.on('stdout', (log) => { | ||
logs.push(log) | ||
}) | ||
next.on('stderr', (log) => { | ||
logs.push(log) | ||
}) | ||
|
||
const browser = await next.browser('/form') | ||
await browser.elementByCss('#size-1mb').click() | ||
|
||
await check(() => { | ||
return logs.some((log) => log.includes('size = 1048576')) ? 'yes' : '' | ||
}, 'yes') | ||
|
||
await browser.elementByCss('#size-2mb').click() | ||
await check(() => { | ||
return logs.some((log) => log.includes('size = 2097152')) ? 'yes' : '' | ||
}, 'yes') | ||
Comment on lines
+151
to
+154
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about the 3mb one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When clicking the 3mb I think it said I guess it should throw instead, but busboy does not support that. |
||
}) | ||
} | ||
} | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
async function action(formData) { | ||
'use server' | ||
const payload = formData.get('payload').toString() | ||
console.log('size =', payload.length) | ||
} | ||
|
||
export default function Page() { | ||
return ( | ||
<> | ||
<form action={action}> | ||
<input | ||
type="hidden" | ||
name="payload" | ||
value={'a'.repeat(1024 * 1024 * 1)} | ||
/> | ||
<button type="submit" id="size-1mb"> | ||
SUBMIT 1mb | ||
</button> | ||
</form> | ||
<form action={action}> | ||
<input | ||
type="hidden" | ||
name="payload" | ||
value={'a'.repeat(1024 * 1024 * 2)} | ||
/> | ||
<button type="submit" id="size-2mb"> | ||
SUBMIT 2mb | ||
</button> | ||
</form> | ||
<form action={action}> | ||
<input | ||
type="hidden" | ||
name="payload" | ||
value={'a'.repeat(1024 * 1024 * 3)} | ||
/> | ||
<button type="submit" id="size-3mb"> | ||
SUBMIT 3mb | ||
</button> | ||
</form> | ||
</> | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure what to do here since
busboy
is pr. field whereasnext
is for the whole body.