Skip to content

Context deadline exceeded at start locally #361

Open
@losnappas

Description

@losnappas

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

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)
}
# 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 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions