[GH-ISSUE #840] TypeError: Cannot read properties of undefined (reading 'bind') #8461

Closed
opened 2026-04-13 03:31:45 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @mmikhan on GitHub (Dec 9, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/840

Describe the bug
When using the React Server action to submit a form for the login or registration while disabling JavaScript on the browser to ensure that it still works, it shows the following error:

 GET /test 200 in 68ms
 GET /favicon.ico?favicon.45db1c09.ico 200 in 60ms
 ⨯ TypeError: Cannot read properties of undefined (reading 'bind')
    at bind (webpack://next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js:3713:22)
    at async (webpack://next/dist/src/server/app-render/action-handler.ts:797:27)
    at async handleAction (webpack://next/dist/src/server/app-render/action-handler.ts:617:4)
    at async renderToHTMLOrFlightImpl (webpack://next/dist/src/server/app-render/app-render.tsx:1310:34)
    at async doRender (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/base-server.ts:2666:21)
    at async responseGenerator (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/base-server.ts:3027:21)
    at async DevServer.renderToResponseWithComponentsImpl (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/base-server.ts:3039:23)
    at async DevServer.renderPageComponent (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/base-server.ts:3597:15)
    at async DevServer.renderToResponseImpl (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/base-server.ts:3659:23)
    at async DevServer.pipeImpl (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/base-server.ts:1698:20)
    at async NextNodeServer.handleCatchallRenderRequest (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/next-server.ts:1034:6)
    at async DevServer.handleRequestImpl (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/base-server.ts:1462:8)
    at async (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/dev/next-dev-server.ts:514:13)
    at async Span.traceAsyncFn (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/trace/trace.ts:143:13)
    at async DevServer.handleRequest (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/dev/next-dev-server.ts:512:19)
    at async invokeRender (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/lib/router-server.ts:284:10)
    at async handleRequest (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/lib/router-server.ts:530:15)
    at async requestHandlerImpl (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/lib/router-server.ts:576:6)
    at async Server.requestListener (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/lib/start-server.ts:146:6)
  795 |             })
  796 |             const formData = await fakeRequest.formData()
> 797 |             const action = await decodeAction(formData, serverModuleMap)
      |                           ^
  798 |             if (typeof action === 'function') {
  799 |               // Only warn if it's a server action, otherwise skip for other post requests
  800 |               warnBadServerActionRequest() {
  page: '/test'
}
 POST /test 500 in 282ms

To Reproduce
Steps to reproduce the behavior:

  1. Create a simple HTML form and use Server action to submit it
    <form
      className="mt-8 max-w-md w-full"
      action={async () => {
        "use server";
        await auth.api.signInEmail({
          body: { email: "user@email.com", password: "password" },
        });
      }}
    >
      <label className="block">
        <span className="text-gray-700">Name</span>
        <input
          type="text"
          name="name"
          id="name"
          className="mt-1 block border w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"
        />
      </label>
    
      <button
        type="submit"
        className="mt-4 w-full bg-indigo-600 hover:bg-indigo-700 text-white font-semibold py-2 px-4 rounded"
      >
        Submit
      </button>
    </form>
    
  2. Disable JavaScript on the browser
  3. Submit the form
  4. See error in server side console

Expected behavior
Submit the form without the errors while JavaScript is disabled on the browser. Using Server action is the whole point to ensure the form works while JavaScript is disabled.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • React v19.0
  • Next.js v15.0.4
  • Better Auth v1.0.10
Originally created by @mmikhan on GitHub (Dec 9, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/840 **Describe the bug** When using the React Server action to submit a form for the login or registration while disabling JavaScript on the browser to ensure that it still works, it shows the following error: ```bash GET /test 200 in 68ms GET /favicon.ico?favicon.45db1c09.ico 200 in 60ms ⨯ TypeError: Cannot read properties of undefined (reading 'bind') at bind (webpack://next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js:3713:22) at async (webpack://next/dist/src/server/app-render/action-handler.ts:797:27) at async handleAction (webpack://next/dist/src/server/app-render/action-handler.ts:617:4) at async renderToHTMLOrFlightImpl (webpack://next/dist/src/server/app-render/app-render.tsx:1310:34) at async doRender (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/base-server.ts:2666:21) at async responseGenerator (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/base-server.ts:3027:21) at async DevServer.renderToResponseWithComponentsImpl (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/base-server.ts:3039:23) at async DevServer.renderPageComponent (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/base-server.ts:3597:15) at async DevServer.renderToResponseImpl (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/base-server.ts:3659:23) at async DevServer.pipeImpl (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/base-server.ts:1698:20) at async NextNodeServer.handleCatchallRenderRequest (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/next-server.ts:1034:6) at async DevServer.handleRequestImpl (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/base-server.ts:1462:8) at async (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/dev/next-dev-server.ts:514:13) at async Span.traceAsyncFn (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/trace/trace.ts:143:13) at async DevServer.handleRequest (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/dev/next-dev-server.ts:512:19) at async invokeRender (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/lib/router-server.ts:284:10) at async handleRequest (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/lib/router-server.ts:530:15) at async requestHandlerImpl (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/lib/router-server.ts:576:6) at async Server.requestListener (node_modules/.pnpm/next@15.0.4_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/next/src/server/lib/start-server.ts:146:6) 795 | }) 796 | const formData = await fakeRequest.formData() > 797 | const action = await decodeAction(formData, serverModuleMap) | ^ 798 | if (typeof action === 'function') { 799 | // Only warn if it's a server action, otherwise skip for other post requests 800 | warnBadServerActionRequest() { page: '/test' } POST /test 500 in 282ms ``` **To Reproduce** Steps to reproduce the behavior: 1. Create a simple HTML form and use Server action to submit it ```tsx <form className="mt-8 max-w-md w-full" action={async () => { "use server"; await auth.api.signInEmail({ body: { email: "user@email.com", password: "password" }, }); }} > <label className="block"> <span className="text-gray-700">Name</span> <input type="text" name="name" id="name" className="mt-1 block border w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50" /> </label> <button type="submit" className="mt-4 w-full bg-indigo-600 hover:bg-indigo-700 text-white font-semibold py-2 px-4 rounded" > Submit </button> </form> ``` 3. Disable JavaScript on the browser 4. Submit the form 5. See error in server side console **Expected behavior** Submit the form without the errors while JavaScript is disabled on the browser. Using Server action is the whole point to ensure the form works while JavaScript is disabled. **Screenshots** If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - React v19.0 - Next.js v15.0.4 - Better Auth v1.0.10
GiteaMirror added the locked label 2026-04-13 03:31:45 -05:00
Author
Owner

@mmikhan commented on GitHub (Dec 10, 2024):

It turns out an issue to my own implementation even though I am pretty sure that I tried the same thing before posting here but that that didn't work before but now it does.

Anyways, I had to use the correct API from Better Auth and that did it this time:

await authClient.signUp.email()

Sorry, had to reopen. I was wrong. The error described in the issue is true and persists. It seems the auth.api isn't getting some information when the JavaScript is disabled on the browser. Not sure what it is though

<!-- gh-comment-id:2532902682 --> @mmikhan commented on GitHub (Dec 10, 2024): ~It turns out an issue to my own implementation even though I am pretty sure that I tried the same thing before posting here but that that didn't work before but now it does.~ ~Anyways, I had to use the correct API from [Better Auth](https://www.better-auth.com/docs/basic-usage#sign-up) and that did it this time:~ ~await authClient.signUp.email()~ Sorry, had to reopen. I was wrong. The error described in the issue is true and persists. It seems the `auth.api` isn't getting some information when the JavaScript is disabled on the browser. Not sure what it is though
Author
Owner

@Kinfe123 commented on GitHub (Apr 11, 2025):

can you share us video walkthrough of an error since i have tried and working perfectly fine ? will. reopen it if it still a case for you and others

<!-- gh-comment-id:2796903293 --> @Kinfe123 commented on GitHub (Apr 11, 2025): can you share us video walkthrough of an error since i have tried and working perfectly fine ? will. reopen it if it still a case for you and others
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8461