Skip to content
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?]: Could not parse content as FormData on AWS Lambda #1289

Closed
2 tasks done
russbiggs opened this issue Jan 28, 2024 · 2 comments
Closed
2 tasks done

[Bug?]: Could not parse content as FormData on AWS Lambda #1289

russbiggs opened this issue Jan 28, 2024 · 2 comments
Labels
bug Something isn't working vinxi related to vinxi

Comments

@russbiggs
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

When deploying to AWS Lambda and submitting a form in an application the submission fails and returns at HTTP 500.

This occurs even with a simple form and corresponding action

import {formAction} from '~/server';

export default function FormPage() {
  return (
    <main>
      <h1>Form</h1>
      <form action={formAction} method='post'>
        <label for="name">Name</label>
        <input type="text" name="name" id="name-input" />
        <label for="name">Password</label>
        <input type="password" name="name" id="password-input" />
        <button type="submit">
          Submit
        </button>
      </form>
    </main>
  );
}
export async function formTest(formData: FormData) {
    const name = String(formData.get('name'));
    const password = String(formData.get('password'));
    console.log(name, password);
    throw redirect('/');
}

...

export const formAction = action(formTest, 'form-action');

The form fails and responds with a HTTP500 and the following error:

_Request.formData: Could not parse content as FormData.

The full traceback

at webidl.errors.exception (node:internal/deps/undici/undici:1432:14) at _Request.formData (node:internal/deps/undici/undici:4505:33) at async Object.D$2 [as handler] (./server/chunks/nitro/aws-lambda.mjs:7596:14) at async Object.handler (./server/chunks/nitro/aws-lambda.mjs:3471:19) at async toNodeHandle (./server/chunks/nitro/aws-lambda.mjs:3660:7) at async Runtime.handler (./server/chunks/nitro/aws-lambda.mjs:8890:13) | 2024-01-28T16:03:43.140Z ec66aefc-a464-426b-a65b-a99ae9dbcfdd ERROR [nitro] [request error] [unhandled] _Request.formData: Could not parse content as FormData. at webidl.errors.exception (node:internal/deps/undici/undici:1432:14) at _Request.formData (node:internal/deps/undici/undici:4505:33) at async Object.D$2 [as handler] (./server/chunks/nitro/aws-lambda.mjs:7596:14) at async Object.handler (./server/chunks/nitro/aws-lambda.mjs:3471:19) at async toNodeHandle (./server/chunks/nitro/aws-lambda.mjs:3660:7) at async Runtime.handler (./server/chunks/nitro/aws-lambda.mjs:8890:13)

The form data fields appear to passing to the body correctly. Perhaps there is something in the Lambda node runtime that im missing?

Forms work fine in the local development server and when building to node.

Expected behavior 🤔

Forms should submit normally.

Steps to reproduce 🕹

An minimal reproducible example repo is available here:

https://github.com/russbiggs/solid-start-form-lambda

This include AWS CDK for deploying to AWS lambda and generating an public URL.

Context 🔦

Attempting to deploy a solid-start application with forms on AWS lambda.

Your environment 🌎

System:
    OS: MacOS Ventura 13.1
    Arch: Apple M1 arm64
Binaries:
    Node: v18.15.0
    npm: 9.8.1
npmPackages:
    vinxi: 0.1.10
    solid-js: 1.8.12
    @solidjs/meta: "^0.29.2",
    @solidjs/router: "^0.10.10",
    @solidjs/start: "^0.4.11",
@russbiggs russbiggs added the bug Something isn't working label Jan 28, 2024
@ryansolid ryansolid added the vinxi related to vinxi label Jan 29, 2024
@russbiggs
Copy link
Author

This issue seems to be have been resolved somewhere between vinxi 0.1.10 and 0.3.10 and/or solid start 0.4.11 and 0.7.5. Running the demo repo listed above on lambda with the updated version does seem to submit as expected.

@ryansolid
Copy link
Member

Awesome. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vinxi related to vinxi
Projects
None yet
Development

No branches or pull requests

2 participants