aws / aws/aws-lambda-go

Context deadline exceeded at start locally

Open
#361 7 comments 9 reactions 0 assignees View on GitHub
troubleshooting
Dominant language
Go
Stars
3.8k
Forks
578
Avg merge
8h 18m
Merged PRs (30d)
1

Description

I'm running the lambda image locally, and long story short, it starts off with an expired context deadline.

```golang
package main

import (
"context"
"log"

"github.com/aws/aws-lambda-go/lambda"
)

func Handler(ctx context.Context) {
log.Println(ctx.Err())
log.Println(ctx.Deadline())
}
func main() {
lambda.Start(Handler)
}
```

```dockerfile
# installer
FROM golang:1.15-alpine3.12@sha256:4d8abd16b03209b30b48f69a2e10347aacf7ce65d8f9f685e8c3e20a512234d9 as installer
WORKDIR /build

COPY ./go.mod ./go.sum ./

RUN go mod download

# builder
FROM installer as builder

COPY . ./

RUN CGO_ENABLED=0 GOOS=linux go build -o Main ./main.go

# release
FROM public.ecr.aws/lambda/go:latest

COPY --from=builder /build/Main .

CMD ["./Main"]
```

`curl localhost:8080/2015-03-31/functions/function/invocations`

logs

```
time="2021-02-27T23:20:12.39" level=info msg="exec '/var/runtime/bootstrap' (cwd=/var/task, handler=)"
time="2021-02-27T23:20:48.623" level=info msg="extensionsDisabledByLayer(/opt/disable-extensions-jwigqn8j) -> stat /opt/disable-extensions-jwigqn8j: no such file or directory"
time="2021-02-27T23:20:48.624" level=warning msg="Cannot list external agents" error="open /opt/extensions: no such file or directory"
START RequestId: 9af7aefe-d612-4f5e-9e75-c9cdeadab9f5 Version: $LATEST
2021/02/27 23:20:48 context deadline exceeded
2021/02/27 23:20:48 2021-02-27 23:20:48.631152628 +0000 UTC true
END RequestId: 9af7aefe-d612-4f5e-9e75-c9cdeadab9f5
REPORT RequestId: 9af7aefe-d612-4f5e-9e75-c9cdeadab9f5 Init Duration: 0.20 ms Duration: 7.73 ms Billed Duration: 100 ms Memory Size: 3008 MB Max Memory Used: 3008 MB
```

"context deadline exceeded"

What am I missing? [Here](https://docs.aws.amazon.com/lambda/latest/dg/golang-context.html) it says

> Context methods
Deadline – Returns the date that the execution times out, in Unix time milliseconds.

But it's essentially returning the starting time instead.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.