openfaas / nats-queue-worker

Queue-worker for OpenFaaS with NATS Streaming
https://docs.openfaas.com/reference/async/
MIT License
129 stars 59 forks source link

Fixed bad pointer when function fails #89

Closed andeplane closed 4 years ago

andeplane commented 4 years ago

If function call ends up giving 503, nats-queue-worker crashes with panic: runtime error: invalid memory address or nil pointer dereference when trying to do callback.

Description

If X-Callback-Url is set, and the function call gives 503, functionRes is nil, but we try to evaluate functionRes.Header.Get("X-Duration-Seconds") in the postResult function. This leads to null pointer error and a dying pod. The call is then being retried multiple times on any new queue-worker pod starting.

This PR adds the timeout directly to the headers instead.

Motivation and Context

Crashing queue worker in the state mentioned above.

Types of changes

Checklist:

derek[bot] commented 4 years ago

Thank you for your contribution. I've just checked and your commit doesn't appear to be signed-off. That's something we need before your Pull Request can be merged. Please see our contributing guide. Tip: if you only have one commit so far then run: git commit --amend --signoff and then git push --force.