sveltejs / kit

web development, streamlined
https://svelte.dev/docs/kit
MIT License
18.66k stars 1.93k forks source link

Invalid request body #5370

Closed KeithAndreRose closed 2 years ago

KeithAndreRose commented 2 years ago

Describe the bug

I upgraded svelte-kit to its latest version today. I configured my project to use the new vite.config.js setup, however now "Invalid request body" is the only response I get in the browser for all routes (except proxy rules). It's occurring while using the default starter/skeleton project as well.

Screen Shot 2022-07-05 at 6 23 32 PM Screen Shot 2022-07-05 at 6 23 51 PM

There are no errors reported in the terminal. Configured server proxy rules do resolve.

Reproduction

npm create svelte my-app cd my-app npm install npm run dev -- --open

Logs

➜  my-app pnpm dev -d             

> my-app@0.0.1 dev /Users/keithrose/Workspace/svelte-test/my-app
> vite dev "-d"

(node:56433) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
  vite:vite-plugin-svelte svelte inspector path: /Users/keithrose/Workspace/svelte-test/my-app/node_modules/@sveltejs/vite-plugin-svelte/src/ui/inspector/ +0ms
  vite:config native esm config loaded in 144.40ms URL {
  href: 'file:///Users/keithrose/Workspace/svelte-test/my-app/vite.config.js',
  origin: 'null',
  protocol: 'file:',
  username: '',
  password: '',
  host: '',
  hostname: '',
  port: '',
  pathname: '/Users/keithrose/Workspace/svelte-test/my-app/vite.config.js',
  search: '',
  searchParams: URLSearchParams {},
  hash: ''
} +0ms
  vite:vite-plugin-svelte findSvelteDependencies: searching svelte dependencies in /Users/keithrose/Workspace/svelte-test/my-app +38ms
  vite:vite-plugin-svelte adding bare svelte packages to optimizeDeps.include: svelte/animate, svelte/easing, svelte/internal, svelte/motion, svelte/store, svelte/transition, svelte  +1ms
  vite:vite-plugin-svelte automatically excluding found svelte dependencies:  +0ms
  vite:vite-plugin-svelte reincluding transitive dependencies of excluded svelte dependencies [] +0ms
  vite:vite-plugin-svelte additional vite config {
  resolve: {
    mainFields: [ 'svelte', 'module', 'jsnext:main', 'jsnext' ],
    dedupe: [
      'svelte/animate',
      'svelte/easing',
      'svelte/internal',
      'svelte/motion',
      'svelte/ssr',
      'svelte/store',
      'svelte/transition',
      'svelte',
      'svelte-hmr/runtime/hot-api-esm.js',
      'svelte-hmr/runtime/proxy-adapter-dom.js',
      'svelte-hmr'
    ]
  },
  optimizeDeps: {
    include: [
      'svelte/animate',
      'svelte/easing',
      'svelte/internal',
      'svelte/motion',
      'svelte/store',
      'svelte/transition',
      'svelte'
    ],
    exclude: [ 'svelte-hmr' ]
  },
  ssr: { noExternal: [], external: [] }
} +1ms
  vite:vite-plugin-svelte Setting compilerOptions.hydratable: true for SvelteKit +12ms
  vite:vite-plugin-svelte resolved options {
  hot: { injectCss: false },
  compilerOptions: { css: false, dev: true, hydratable: true },
  extensions: [ '.svelte' ],
  emitCss: true,
  preprocess: [
    {
      defaultLanguages: [Object],
      markup: [AsyncFunction: markup],
      script: [AsyncFunction: script],
      style: [AsyncFunction: style]
    },
    { style: [Function: style] }
  ],
  kit: {
    adapter: { name: '@sveltejs/adapter-auto', adapt: [Function: adapt] }
  },
  configFile: '/Users/keithrose/Workspace/svelte-test/my-app/svelte.config.js',
  root: '/Users/keithrose/Workspace/svelte-test/my-app',
  isBuild: false,
  isServe: true,
  isDebug: true,
  isProduction: false
} +1ms
  vite:vite-plugin-svelte inspector disabled, could not find config +1ms
  vite:config using resolved config: {
  vite:config   plugins: [
  vite:config     'vite:pre-alias',
  vite:config     'alias',
  vite:config     'vite-plugin-svelte',
  vite:config     'vite-plugin-svelte:inspector',
  vite:config     'vite:modulepreload-polyfill',
  vite:config     'vite:resolve',
  vite:config     'vite:optimized-deps',
  vite:config     'vite:html-inline-proxy',
  vite:config     'vite:css',
  vite:config     'vite:esbuild',
  vite:config     'vite:json',
  vite:config     'vite:wasm',
  vite:config     'vite:worker',
  vite:config     'vite:asset',
  vite:config     'vite-plugin-svelte-kit',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:worker-import-meta-url',
  vite:config     'vite:client-inject',
  vite:config     'vite:import-analysis'
  vite:config   ],
  vite:config   server: {
  vite:config     preTransformRequests: true,
  vite:config     fs: { strict: true, allow: [Array], deny: [Array] },
  vite:config     port: 3000,
  vite:config     strictPort: true,
  vite:config     watch: { ignored: [Array] }
  vite:config   },
  vite:config   resolve: {
  vite:config     dedupe: [
  vite:config       'svelte/animate',
  vite:config       'svelte/easing',
  vite:config       'svelte/internal',
  vite:config       'svelte/motion',
  vite:config       'svelte/ssr',
  vite:config       'svelte/store',
  vite:config       'svelte/transition',
  vite:config       'svelte',
  vite:config       'svelte-hmr/runtime/hot-api-esm.js',
  vite:config       'svelte-hmr/runtime/proxy-adapter-dom.js',
  vite:config       'svelte-hmr'
  vite:config     ],
  vite:config     mainFields: [ 'svelte', 'module', 'jsnext:main', 'jsnext' ],
  vite:config     alias: [ [Object], [Object], [Object], [Object], [Object] ]
  vite:config   },
  vite:config   optimizeDeps: {
  vite:config     include: [
  vite:config       'svelte/animate',
  vite:config       'svelte/easing',
  vite:config       'svelte/internal',
  vite:config       'svelte/motion',
  vite:config       'svelte/store',
  vite:config       'svelte/transition',
  vite:config       'svelte'
  vite:config     ],
  vite:config     exclude: [ 'svelte-hmr' ],
  vite:config     esbuildOptions: { keepNames: undefined, preserveSymlinks: undefined }
  vite:config   },
  vite:config   ssr: { noExternal: [], external: [] },
  vite:config   base: '/',
  vite:config   build: {
  vite:config     target: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
  vite:config     polyfillModulePreload: true,
  vite:config     outDir: 'dist',
  vite:config     assetsDir: 'assets',
  vite:config     assetsInlineLimit: 4096,
  vite:config     cssCodeSplit: true,
  vite:config     cssTarget: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
  vite:config     sourcemap: false,
  vite:config     rollupOptions: {
  vite:config       input: '/Users/keithrose/Workspace/svelte-test/my-app/.svelte-kit/runtime/client/start.js'
  vite:config     },
  vite:config     minify: 'esbuild',
  vite:config     terserOptions: {},
  vite:config     write: true,
  vite:config     emptyOutDir: null,
  vite:config     manifest: false,
  vite:config     lib: false,
  vite:config     ssr: false,
  vite:config     ssrManifest: false,
  vite:config     reportCompressedSize: true,
  vite:config     chunkSizeWarningLimit: 500,
  vite:config     watch: null,
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }
  vite:config   },
  vite:config   preview: {
  vite:config     port: 3000,
  vite:config     strictPort: true,
  vite:config     host: undefined,
  vite:config     https: undefined,
  vite:config     open: undefined,
  vite:config     proxy: undefined,
  vite:config     cors: undefined,
  vite:config     headers: undefined
  vite:config   },
  vite:config   root: '/Users/keithrose/Workspace/svelte-test/my-app',
  vite:config   configFile: '/Users/keithrose/Workspace/svelte-test/my-app/vite.config.js',
  vite:config   configFileDependencies: [ '/Users/keithrose/Workspace/svelte-test/my-app/vite.config.js' ],
  vite:config   inlineConfig: {
  vite:config     root: undefined,
  vite:config     base: undefined,
  vite:config     mode: undefined,
  vite:config     configFile: undefined,
  vite:config     logLevel: undefined,
  vite:config     clearScreen: undefined,
  vite:config     server: {}
  vite:config   },
  vite:config   publicDir: '/Users/keithrose/Workspace/svelte-test/my-app/public',
  vite:config   cacheDir: '/Users/keithrose/Workspace/svelte-test/my-app/node_modules/.vite',
  vite:config   command: 'serve',
  vite:config   mode: 'development',
  vite:config   isWorker: false,
  vite:config   isProduction: false,
  vite:config   env: { BASE_URL: '/', MODE: 'development', DEV: true, PROD: false },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   logger: {
  vite:config     hasWarned: false,
  vite:config     info: [Function: info],
  vite:config     warn: [Function: warn],
  vite:config     warnOnce: [Function: warnOnce],
  vite:config     error: [Function: error],
  vite:config     clearScreen: [Function: clearScreen],
  vite:config     hasErrorLogged: [Function: hasErrorLogged]
  vite:config   },
  vite:config   packageCache: Map(0) {},
  vite:config   createResolver: [Function: createResolver],
  vite:config   worker: {
  vite:config     format: 'iife',
  vite:config     plugins: [
  vite:config       [Object], [Object],
  vite:config       [Object], [Object],
  vite:config       [Object], [Object],
  vite:config       [Object], [Object],
  vite:config       [Object], [Object],
  vite:config       [Object], [Object],
  vite:config       [Object], [Object],
  vite:config       [Object], [Object],
  vite:config       [Object]
  vite:config     ],
  vite:config     rollupOptions: {}
  vite:config   }
  vite:config } +54ms
  vite:deps Hash is consistent. Skipping. Use --force to override. +0ms

  vite v2.9.13 dev server running at:

  > Local: http://localhost:3000/
  > Network: use `--host` to expose

  ready in 373ms.

  vite:resolve 1.91ms /.svelte-kit/generated/root.svelte -> /Users/keithrose/Workspace/svelte-test/my-app/.svelte-kit/generated/root.svelte +0ms
  vite:load 1.59ms [fs] /.svelte-kit/generated/root.svelte +0ms
  vite:vite-plugin-svelte setting cssHash s-cCKfmRoJfo02 for /.svelte-kit/generated/root.svelte +5s
  vite:vite-plugin-svelte transform returns compiled js for /Users/keithrose/Workspace/svelte-test/my-app/.svelte-kit/generated/root.svelte +61ms
  vite:import-analysis 0.63ms [0 imports rewritten] .svelte-kit/generated/root.svelte +0ms
  vite:transform 64.87ms /.svelte-kit/generated/root.svelte +0ms
  vite:resolve 0.34ms /.svelte-kit/runtime/paths.js -> /Users/keithrose/Workspace/svelte-test/my-app/.svelte-kit/runtime/paths.js +116ms
  vite:load 4.08ms [fs] /.svelte-kit/runtime/paths.js +116ms
  vite:import-analysis 0.05ms [no imports] .svelte-kit/runtime/paths.js +53ms
  vite:transform 0.58ms /.svelte-kit/runtime/paths.js +53ms
  vite:time 216.33ms / +0ms
  vite:time 1.15ms /favicon.ico +50ms

System Info

System:
    OS: macOS 12.5
    CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
    Memory: 122.75 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.7.0 - ~/.nvm/versions/node/v16.7.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.20.3 - ~/.nvm/versions/node/v16.7.0/bin/npm
  Browsers:
    Brave Browser: 103.1.40.107
    Chrome: 103.0.5060.53
    Firefox Nightly: 84.0a1
    Safari: 15.6
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.53 
    @sveltejs/kit: next => 1.0.0-next.359 
    svelte: ^3.44.0 => 3.48.0 
    vite: ^2.9.13 => 2.9.13

Severity

blocking all usage of SvelteKit

Additional Information

No response

Rich-Harris commented 2 years ago

I can reproduce if I downgrade to Node 16.7. Haven't yet figured out why. In the meantime, if you're able to upgrade to the latest 16.x (or 18.x), that should fix things

KeithAndreRose commented 2 years ago

Can confirm things run smooth upgrading to node v16.15.1, thanks! Seems to occur on node versions below v16.9.0

rajasegar commented 2 years ago

Why it is breaking in a patch version upgrade of svelte-kit? Shouldn't this be a breaking change for svelte-kit?

Rich-Harris commented 2 years ago

@rajasegar it's not like it was intentional

georgdonner commented 2 years ago

I just created a new project based on the Svelte demo app and testing out the Sverdle, I am getting the same response as you guys above "Invalid request body" (see screenshot). I have also tested this with a skeleton project and a custom POST endpoint and am running into the same issue there as well. Is anyone else able to reproduce this?

Node versions tested: v16.15.1, v16.18.0 and v18.12.0

"@sveltejs/adapter-auto": "1.0.0-next.84", "@sveltejs/kit": "1.0.0-next.525",

Screenshot 2022-10-27 at 20 16 04
mylastore commented 10 months ago

I am getting the same error with "Invalid request body" node version 21.4.0 "vite": "^4.4.2" "@sveltejs/kit": "^1.27.4",

RSWilli commented 10 months ago

@mylastore I also got the same issue today and I opened https://github.com/sveltejs/kit/issues/11334 for it. If you do have a reproduction please add it there.