sveltejs / kit

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

[@sveltejs/adapter-vercel] Function name length check #12803

Open vjpr opened 3 weeks ago

vjpr commented 3 weeks ago

Describe the bug

https://vercel.com/docs/functions/limitations#functions-name

The following limits apply to the function's name when using Node.js runtime:

Maximum length of 128 characters. This includes the extension of the file (e.g. apps/admin/api/my-function.js is 29 characters) No spaces are allowed. Replace them with a - or _ (e.g. api/my function.js isn't allowed)

There should be a check for this at this line:

handler: path.relative(base + ancestor, entry),

Reproduction

Create a deeply nested folder structure in your git repo and setup the build in that directory.

Logs

No response

System Info

System:
    OS: macOS 15.0.1
    CPU: (16) arm64 Apple M3 Max
    Memory: 711.11 MB / 128.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.8.0 - ~/Library/pnpm/node
    npm: 10.8.2 - ~/Library/pnpm/npm
    pnpm: 9.12.1 - ~/Library/pnpm/pnpm
    bun: 1.1.30 - ~/.bun/bin/bun
    Watchman: 2024.08.19.00 - /opt/homebrew/bin/watchman
  Browsers:
    Safari: 18.0.1
  npmPackages:
    @sveltejs/adapter-auto: ^3.2.5 => 3.2.5
    @sveltejs/adapter-node: ^5.2.6 => 5.2.6
    @sveltejs/adapter-vercel: ^5.4.5 => 5.4.5
    @sveltejs/kit: ^2.7.0 => 2.7.0
    @sveltejs/vite-plugin-svelte: ^3.1.2 => 3.1.2
    svelte: ^4.2.19 => 4.2.19
    vite: ^5.4.8 => 5.4.8


### Severity

blocking all usage of SvelteKit

### Additional Information

_No response_
vjpr commented 3 weeks ago

This happened to me because I used vercel deploy --prebuilt and it included the path up to ~/.npmrc in my home dir which made the paths really long. They were relative to my home dir.


So the issue was "Users/Vaughan/.npmrc" being include in the traced.fileList.

There should be a check for this...or nodeFileTrace should be configurable.

For me the ideal solution is to look for pnpm-workspace.yaml and then throw a warning if there is something found higher up than this.