question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Different behaviour when body is missing

See original GitHub issue

Repro steps

given the following function.json

{
  "entryPoint": "handler",
  "bindings": [
    {
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [ "get" ],
      "route": "embed/{appId}",
      "authLevel": "anonymous"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "$return"
    }
  ],
  "disabled": false
}

and the following handler

export function handler(ctx, req) {
  return Promise.resolve({
    status: 302, headers: { Location: '/new_url' }
  })
}

Expected behavior

redirect to /new_url

Actual behavior

returns status 200, with JSON body: { status: 302, headers: { Location: '/new_url' } }

Known workarounds

adding an empty body causes the redirect to be followed

export function handler(ctx, req) {
  return Promise.resolve({
    body: '', status: 302, headers: { Location: '/new_url' }
  })
}

Is this behaviour intentional? Seems very confusing

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
cloudkitecommented, Jan 12, 2017

@mamaso didn’t realise you can do body: undefined, thanks!

1reaction
cloudkitecommented, Nov 23, 2016

Thanks for clarifying! Would personally prefer it to always treat object as response object, for consistency sake. But don’t think its a major issue either way

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Psychology of Missing Someone: 5 Ways to Cope With ...
When you miss someone, your body and brain go through a painful response. The grieving process may affect your appetite, ability to sleep, ......
Read more >
Identifying and Treating Maladaptive Behavior
Let's explore some types of maladaptive behavior and signs you should seek treatment. ... They end up missing out on something they enjoy....
Read more >
Clinical Manifestations of Body Memories: The Impact ...
Body memories of inescapability and helplessness due to an experienced inability to fight or flee during a traumatic event have therefore been ...
Read more >
(PDF) Cognitive-Behavioral Correlates of Psychological ...
Relatives of missing persons (n = 134) completed self-report measures of negative cognitions, avoidance behaviors, PGD, PTSD, and MDD.
Read more >
The feeling a limb doesn't belong is linked to lack of brain ...
People with body integrity dysphoria (BID) often feel as though one of their healthy limbs isn't meant to be a part of their...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found