Skip to content

Response body object should not be disturbed or locked #85

@MikeyZhang75

Description

@MikeyZhang75

When using clerkPlugin and expecting data from the body, you encounter: "Response body object should not be disturbed or locked"

What I've Tried:

  • Removing the Body Schema:
{
  body: t.Object({
    name: t.String(),
  }),
}
  • Removing the auth Parameter(resolves the issue):
async ({ body }) => { ... }

Tested on Elysia versions 1.2.25 and 1.2.24.

Full API Code:

// app/api/[[...slugs]]/route.ts
import { Elysia, error, t } from "elysia";
import { swagger } from "@elysiajs/swagger";
import { clerkPlugin } from "elysia-clerk";

const app = new Elysia({ prefix: "/api" })
	.use(swagger())
	.use(clerkPlugin())
	.post(
		"/user",
		async ({ auth, body }) => {
			if (!auth?.userId) {
				return error(401);
			}

			return body;
		},
		{
			body: t.Object({
				name: t.String(),
			}),
		},
	);

export const GET = app.handle;
export const POST = app.handle;
Image

Package.json:

{
  "name": "clerk-elysia-test",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev --turbopack",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@clerk/nextjs": "^6.12.8",
    "@elysiajs/swagger": "^1.2.2",
    "elysia": "^1.2.25",
    "elysia-clerk": "^0.9.7",
    "next": "15.2.3",
    "react": "^19.0.0",
    "react-dom": "^19.0.0"
  },
  "devDependencies": {
    "@eslint/eslintrc": "^3",
    "@tailwindcss/postcss": "^4",
    "@types/bun": "^1.2.5",
    "@types/node": "^20",
    "@types/react": "^19",
    "@types/react-dom": "^19",
    "eslint": "^9",
    "eslint-config-next": "15.2.3",
    "tailwindcss": "^4",
    "typescript": "^5"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions