Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapter Vercel: global is not defined when build for edge network #6424

Closed
juanvillacortac opened this issue Aug 30, 2022 · 1 comment · Fixed by #6425
Closed

Adapter Vercel: global is not defined when build for edge network #6424

juanvillacortac opened this issue Aug 30, 2022 · 1 comment · Fixed by #6425

Comments

@juanvillacortac
Copy link
Contributor

Describe the bug

When a project depends on packages (like @trpc/client, for example) that reference the global variable and in the adapter-vercel config you pass the edge: true prop, throws a runtime error when a render is hit saying: global is not defined.

Reproduction

Try to deploy to vercel targeting edge functions instead of lamdba a project that imports a lib that reference the nodejs global variable like @trpc/client at any serverside point, like +layout.server.js or +layout.js, and the app should crash.

Logs

No response

System Info

System:
    OS: Linux 5.17 undefined
    CPU: (4) x64 AMD A10-7300 Radeon R6, 10 Compute Cores 4C+6G
    Memory: 2.35 GB / 6.76 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
    npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
  Browsers:
    Firefox: 99.0

Severity

serious, but I can work around it

Additional Information

I will make a PR providing a fix for this bug in a late.

@juanvillacortac juanvillacortac changed the title **Adapter Vercel**: global is not defined when build for edge network *Adapter Vercel*: global is not defined when build for edge network Aug 30, 2022
@juanvillacortac juanvillacortac changed the title *Adapter Vercel*: global is not defined when build for edge network Adapter Vercel: global is not defined when build for edge network Aug 30, 2022
@Rich-Harris
Copy link
Member

To be clear, this is a bug in @trpc/client — unless it's only intended to be used in Node, then it shouldn't be referencing global (and even if it is only intended to be used in Node, globalThis is preferable and has been for a long time), so I would recommend opening an issue on that repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants