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

[Bug?]: RedwoodJS Deploy to Vercel with a vercel.json in the project causes the deploy to loop for 10minutes on vercel #10022

Open
1 task done
RinKimLaw opened this issue Feb 16, 2024 · 16 comments
Labels
bug/needs-info More information is needed for reproduction topic/deployment

Comments

@RinKimLaw
Copy link

What's not working?

This is my vercel.json

{
  "functions": {
    "api/src/functions/minutesync/minutesync.*": {
      "memory": 256,
      "runtime": "@vercel/[email protected]"
    },
    "api/src/functions/asauth/asauth.*": {
      "memory": 512,
      "runtime": "@vercel/[email protected]"
    },
    "api/src/functions/ascallback/ascallback.*": {
      "memory": 128,
      "runtime":"@vercel/[email protected]"
    },
    "api/src/functions/asrefresh/asrefresh.*": {
      "memory": 256,
      "runtime":"@vercel/[email protected]"
    },
    "api/src/functions/bulksync/bulksync.*": {
      "memory": 128,
      "runtime":"@vercel/[email protected]"
    },
    "api/src/functions/graphql.*": {
      "memory": 512,
      "runtime":"@vercel/[email protected]"
    }
  }
}

My project config is defaults for a redwoodjs project on [email protected].

With the vercel.json the build keeps looping again and again for 8-10 minutes and then eventually succeeds

Without the vercel.json the build succeeds in 1m30s

I'm guessing Vercel's default config for RedwoodJS projects is somehow being overridden by my vercel.json, causing this looping behaviour.

How do we reproduce the bug?

Create a new project with RedwoodJS typescript and setup a vercel deploy. Add a vercel.json to the project with some config for the functions.

What's your environment? (If it applies)

System:
    OS: Windows 10 10.0.19045
  Binaries:
    Node: 18.19.0 - ~\AppData\Local\Temp\yarn--1708063642733-0.2390738274290265\node.CMD
    Yarn: 1.22.17 - ~\AppData\Local\Temp\yarn--1708063642733-0.2390738274290265\yarn.CMD
  Browsers:
    Chrome: 121.0.6167.185
    Edge: Chromium (121.0.2277.112)
  npmPackages:
    @redwoodjs/core: 6.6.4 => 6.6.4

Are you interested in working on this?

  • I'm interested in working on this
@RinKimLaw RinKimLaw added the bug/needs-info More information is needed for reproduction label Feb 16, 2024
@jtoar
Copy link
Contributor

jtoar commented Feb 17, 2024

Hey @RinKimLaw I tried making a repro (albeit with just the graphql function) and couldn't reproduce 8-10 minute looping builds. One thing I'm wondering: is the @vercel/redwood package a Vercel runtime? Basically, where did you see docs to use that package as the runtime, or did Vercel support tip you off to that?

I'm wondering if that's the problem. I feel like maybe you should actually end up using the Node.js runtime via @vercel/node?

@timoshishi
Copy link

Hi @jtoar, I'm running into the same issue here trying to extend my function timeouts.

The selection of the runtime is referenced in the docs here. It seems this was suggested by vercel support to a user in this community post.

As it stands, the default deploy that runs the @redwood/vercel builder is not picking up the maxDuration property being exported from my functions so function executions are limited to 15 seconds even on the Pro plan.

@timoshishi
Copy link

It appears that targeting the root graphql file only will allow you to customize options for the server file but not the nested functions. Building will succeed with this configuration

{
  "functions": {
    "api/src/functions/*.*": {
      "maxDuration": 20,
      "runtime": "@vercel/[email protected]"
    }
}

Attempting to set options for a nested function will result in recursive builds

{
  "functions": {
    "api/src/functions/*.*": {
      "maxDuration": 20,
      "runtime": "@vercel/[email protected]"
    },
    "api/src/functions/nestedFunction/*.*": {
      "maxDuration": 300,
      "runtime": "@vercel/[email protected]"
    }
  }
}

I have verified this both with the local vercel build command and in the platform builds.

This restricts customization and pretty much rules out vercel as viable platform for all but the most simple apps built with redwood.

For context I am also running "@redwoodjs/core": "6.6.0"

@RinKimLaw
Copy link
Author

RinKimLaw commented Feb 27, 2024

I think there's a way to configure the vercel.json for redwoodjs that's not completely/accurately documented anywhere because with the default settings (No vercel.json), the project deploys within 1m30s. Also, all the config in my vercel.json is ignored, the memory size is always the default 1024MB.

@dthyresson
Copy link
Contributor

dthyresson commented Mar 4, 2024

I believe that https://community.redwoodjs.com/t/increase-timeout-duration-of-api-in-vercel/5446/3 address this issue with some docs to set the timeout on Vercel.

But I may be wrong?

@dthyresson
Copy link
Contributor

Just to clarify - this issue related to the length of the build time (not the timeout of the function) -- because Vercel is building the redwoodJS app multiple times (once per api/function)?

@timoshishi
Copy link

@dthyresson That documentation only works for the base graphql function. If you try to specify a different timeout or memory settings for the serverless functions in sub-directories, it will build recursively, not just once per function

@RinKimLaw
Copy link
Author

I wonder if there's any update on this? I previously tried to post this as an issue on Vercel's github but couldn't get through. For now it's fine deploying Redwood to vercel with default settings for me, but it's a pretty major issue that neither the function size nor the function timeout can be adjusted using vercel.json.

@dthyresson
Copy link
Contributor

Hi @RinKimLaw - I am trying to remember the details but does this https://redwoodjs.com/docs/deploy/vercel#verceljson-configuration help?

I imagine that one might have to specify a function (not the GraphQL function listed)..

I’d this does not help, could you share an example that does not work as expected?

@RinKimLaw
Copy link
Author

@dthyresson No that config didn't work for me. It eventually deploys after recursively building everything, but neither of the function parameters are honoured (Memory or timeout).

@RinKimLaw
Copy link
Author

Opened an issue on Vercel's side https://github.com/orgs/vercel/discussions/6526

@dthyresson
Copy link
Contributor

@RinKimLaw We will likely have to create a small reproducible case for Vercel to try. Do you have a public repo of a project we can share or could you post the Vercel config you are using to make sure we’re doing the same. Thanks.

@RinKimLaw
Copy link
Author

@dthyresson I can setup a public repo tomorrow to demo the issue.

@dthyresson
Copy link
Contributor

@dthyresson I can setup a public repo tomorrow to demo the issue.

Thank you so much! This will really help as I can share with Vercel, too.

@DrakenKor
Copy link

Hi, just on my personal account -
Here is the test repo - https://github.com/DrakenKor/vercel-redwood-tester
Vercel.json values:

{
  "buildCommand": "yarn rw build",
  "functions": {
    "api/src/functions/tester1/tester1.*": {
      "memory": 256,
      "runtime": "@vercel/[email protected]",
      "maxDuration": 20
    },
    "api/src/functions/graphql.*": {
      "memory": 512,
      "runtime":"@vercel/[email protected]",
      "maxDuration": 30
    }
  }
}

image

Values are not honoured for the tester1 function. The build is also recursive and builds twice, once for each function.

@DrakenKor
Copy link

Vercel deploy settings:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/needs-info More information is needed for reproduction topic/deployment
Projects
None yet
Development

No branches or pull requests

6 participants