sanity-io / sanity

Sanity Studio – Rapidly configure content workspaces powered by structured content
https://www.sanity.io
MIT License
5.06k stars 409 forks source link

Internal server error on 'sanity deploy' #6803

Open artilishes opened 1 month ago

artilishes commented 1 month ago

Describe the bug

I initialised a new Sanity project inside a Nextjs project. When trying to deploy my local schemas with sanity deploy the Deployment fails with an internal server error.

To Reproduce

Steps to reproduce the behavior:

  1. Create a new Sanity project
  2. Use npm create sanity@latest -- --project xxxxxx --dataset production --template clean within your nextjs project
  3. Try sanity deploy
  4. See error:
➜  project git:(develop) ✗ sanity deploy
✔ Checking project info
Your project has not been assigned a studio hostname.
To deploy your Sanity Studio to our hosted Sanity.Studio service,
you will need one. Please enter the part you want to use.
? Studio hostname (<value>.sanity.studio): projectName
✔ Clean output folder (2ms)
✔ Build Sanity Studio (8149ms)
✔ Verifying local content
✖ Deploying to Sanity.Studio

Error: Internal Server Error - An internal server error occurred
    at onResponse (~/.nvm/versions/node/v18.18.0/lib/node_modules/sanity/node_modules/@sanity/client/dist/index.cjs:79:13)
    at ~/.nvm/versions/node/v18.18.0/lib/node_modules/sanity/node_modules/get-it/dist/index.cjs:29:17
    at onResponse (~/.nvm/versions/node/v18.18.0/lib/node_modules/sanity/node_modules/get-it/dist/index.cjs:82:22)
    at ~/.nvm/versions/node/v18.18.0/lib/node_modules/sanity/node_modules/get-it/dist/index.cjs:92:55
    at callback (~/.nvm/versions/node/v18.18.0/lib/node_modules/sanity/node_modules/get-it/dist/index.cjs:337:46)
    at ~/.nvm/versions/node/v18.18.0/lib/node_modules/sanity/node_modules/get-it/dist/index.cjs:383:14
    at DestroyableTransform.<anonymous> (~/.nvm/versions/node/v18.18.0/lib/node_modules/sanity/node_modules/get-it/dist/index.cjs:165:11)
    at Object.onceWrapper (node:events:631:28)
    at DestroyableTransform.emit (node:events:529:35)
    at endReadableNT (~/.nvm/versions/node/v18.18.0/lib/node_modules/sanity/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:1010:12)

Expected behavior

Deploy successfully or show a helpful error message.

Screenshots

Screenshot 2024-05-29 at 17 06 00

Which versions of Sanity are you using?

@sanity/cli (global) 3.43.0 (latest: 3.44.0) @sanity/image-url 1.0.2 (up to date) @sanity/ui 2.1.10 (latest: 2.1.14) @sanity/vision 3.42.1 (latest: 3.44.0) sanity 3.42.1 (latest: 3.44.0)

What operating system are you using? macOS 14.5

Which versions of Node.js / npm are you running?

npm 9.8.1 node v18.18.0

Additional context

"dependencies": {
    "@egjs/react-view360": "4.0.0-beta.7",
    "@geometricpanda/storybook-addon-badges": "^2.0.2",
    "@hookform/resolvers": "^3.3.4",
    "@radix-ui/react-accordion": "^1.1.2",
    "@radix-ui/react-label": "^2.0.2",
    "@radix-ui/react-select": "^2.0.0",
    "@radix-ui/react-slot": "^1.0.2",
    "@radix-ui/react-switch": "^1.0.3",
    "@radix-ui/react-toggle": "^1.0.3",
    "@radix-ui/react-toggle-group": "^1.0.4",
    "@sanity/asset-utils": "^1.3.0",
    "@sanity/image-url": "1",
    "@sanity/preview-url-secret": "^1.6.12",
    "@sanity/ui": "^2.1.4",
    "@sanity/vision": "3",
    "@storybook/addon-actions": "^8.0.9",
    "class-variance-authority": "^0.7.0",
    "clsx": "^2.1.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-prettier": "^5.1.3",
    "eslint-plugin-simple-import-sort": "^12.1.0",
    "eslint-plugin-tailwindcss": "^3.15.1",
    "framer-motion": "^11.1.7",
    "leaflet": "^1.9.4",
    "lucide-react": "^0.368.0",
    "next": "14.1.4",
    "next-sanity": "7",
    "next-themes": "^0.3.0",
    "prettier": "^3.2.5",
    "prettier-plugin-tailwindcss": "^0.5.13",
    "react": "^18",
    "react-dom": "^18",
    "react-hook-form": "^7.51.3",
    "react-leaflet": "^4.2.1",
    "react-player": "^2.16.0",
    "rxjs": "^7.8.1",
    "sanity": "3",
    "sonner": "^1.4.41",
    "styled-components": "6",
    "tailwind-merge": "^2.2.2",
    "tailwindcss-animate": "^1.0.7",
    "zod": "^3.23.5"
  },
  "devDependencies": {
    "@chromatic-com/storybook": "^1.3.2",
    "@sanity/eslint-config-studio": "^4.0.0",
    "@storybook/addon-essentials": "^8.0.8",
    "@storybook/addon-interactions": "^8.0.8",
    "@storybook/addon-links": "^8.0.8",
    "@storybook/addon-themes": "^8.0.8",
    "@storybook/blocks": "^8.0.8",
    "@storybook/nextjs": "^8.0.8",
    "@storybook/react": "^8.0.8",
    "@storybook/test": "^8.0.8",
    "@types/leaflet": "^1.9.12",
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "autoprefixer": "^10.0.1",
    "eslint": "^8",
    "eslint-config-next": "14.1.4",
    "eslint-plugin-storybook": "^0.8.0",
    "postcss": "^8",
    "storybook": "^8.0.8",
    "tailwindcss": "^3.3.0",
    "typescript": "^5"
  }
rexxars commented 1 month ago

Could you create a zip file of the sanity studio folder, or at least of the dist folder generated when you run sanity build and upload it somewhere (like here), or send it to espen@sanity.io?

artilishes commented 1 month ago

I just sent you a mail. Thank you!

artilishes commented 4 weeks ago

Hey @rexxars , I figured it out. We have some files in our nextjs' public folder. One of them had no file extension. Once I removed it, the deploy goes through. But I'm wondering, why the sanity deploy is affected by nextjs' public folder and causes an internal server error on your end.😅

rexxars commented 3 weeks ago

Thanks for reporting back, @artilishes ! I have no clue why that would cause issues - and I'm also unable to reproduce with the zip files you provided.

Could you tell us a little bit more about how your folder/project structure is? It sounds like you have a nextjs and a sanity app in the same project structure? Are you deploying from a specific folder that holds the sanity studio?