sst / ion

❍ — a new engine for SST
https://ion.sst.dev
MIT License
1.08k stars 126 forks source link

Function timeout is not applying #466

Open thelegendtubaguy opened 1 month ago

thelegendtubaguy commented 1 month ago

I have a function that I have defined like so:

new sst.aws.Function('MyFunction', {
    environment: {
        ...
    },
    handler: './apps/functions/src/MyFunction.handler',
    memory: '128 MB',
    timeout: '1 minute',
    live: false,
})

It deploys the function correctly with all my env var stuff set, but it does not set the timeout. I have tried 60 seconds, I have tried 1 minute, etc. I don't think it has anything to do with the service that is triggering the function (eventbridge in this case) because when looking at the function's configuration in the console it shows this:

image
thelegendtubaguy commented 1 month ago

If I go into the console and change it to a different value than what I have set in code, SST/Pulumi does not update it back to the value I have set in my code. Seems like this field is not sync'd with SST.

I have also tried setting live: true wondering if that being false was the issue, but I see the same behavior.

jayair commented 1 month ago

Is this in dev or deploy?

thelegendtubaguy commented 1 month ago

Dev, but also the case if I set live to false.

On Tue, May 28, 2024, 5:43 PM Jay @.***> wrote:

Is this in dev or deploy?

— Reply to this email directly, view it on GitHub https://github.com/sst/ion/issues/466#issuecomment-2136226828, or unsubscribe https://github.com/notifications/unsubscribe-auth/AW3734PJRZBTSINQUMS453LZEUCBZAVCNFSM6AAAAABIIJQ5YGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZWGIZDMOBSHA . You are receiving this because you authored the thread.Message ID: @.***>

jayair commented 1 month ago

If you deploy it, does it set it?

thelegendtubaguy commented 1 month ago

Just tested deploying it, no it does not. It's still set at 10 seconds.

Also to be clear, I would expect that if I set the timeout to something else in the console that SST/Pulumi would correct it back to what it's supposed to be. That's how Terraform works. Makes me think this attribute is not being monitored somehow.

jayair commented 4 weeks ago

If that's the case then run a sst refresh first and then do a deploy. More about it here: https://ion.sst.dev/docs/providers/#how-state-works

thelegendtubaguy commented 4 weeks ago

Oh interesting. That's a major shift from how Terraform works. Terraform runs a refresh/plan prior to apply so didn't make sense to me. Is there a way for me to run a plan after doing a refresh before allowing Ion to resolve the diff so I can see what it wants to do? Little scary that it's not refreshing every time.

Regardless of that this still does not work. I just did a refresh then deploy and this function on AWS has a timeout of 10 seconds. Here's its definition:

new sst.aws.Cron('CheckFailedSubscriptionsCron', {
    schedule: 'rate(1 hour)',
    job: {
        environment: {
            CONDUIT_INDEX: '0',
            APP: $app.name,
            STAGE: $app.stage,
            BUS_ARN: bus.arn,
            BUS: bus.name,
        },
        handler: './apps/functions/src/CheckFailedSubscriptions.handler',
        link: [clientIdSecret, clientSecretSecret, table, apiTable],
        live: false,
        permissions: [
            {
                actions: ['ssm:Get*', 'ssm:PutParameter'],
                resources: ['*'],
            },
        ],
        timeout: '2 minutes',
    },
})

If I remove the live: false it still is set at 10 seconds. I seemingly can never get it to respect the timeout setting.

jayair commented 3 weeks ago

So if you edit the value in the console and your local state has a different value, a deploy won't update it.

You need to make sure that your state locally matches what you have set in the console.

For the plan part, we have it on the roadmap.

thelegendtubaguy commented 3 weeks ago

Ah okay, another thing that works different. I guess I didn't realize there wasn't state drift resolution... that seems super odd having come from the Terraform world. That was one of the more exciting features for me that I thought we'd be getting moving away from CloudFormation.

With that in mind, I created a new function. I touched nothing in the console. Its timeout was set at 10 seconds. I added timeout: "60 seconds" while running sst dev, it noticed the file change and tried to deploy but ultimately changed nothing.

I then tried doing an sst deploy and still the function's timeout is set at 10 seconds.

I also tried setting this value to 20 seconds and still saw no change to the timeout actually configured on the function.

jayair commented 3 weeks ago

I see the issue might be specific to how Live handles functions. It isn't deploying your function but a proxy with different set of props. So flipping back and forth between dev and deploy might not be updating it.

jayair commented 3 weeks ago

@fwang let's take a look?