Prisma1: Console logging an Error causes {"error":"Function returned invalid status code: 0. Raw body: empty.last"}

Created on 3 Dec 2017  路  10Comments  路  Source: prisma/prisma1

If an error during a function is encountered, and one attempts to log the error with console.log(e) (where e is an Error object), then the framework will instead log a generic {"error":"Function returned invalid status code: 0. Raw body: empty.last"}.

There's a possibility it may just be that logging an Object in general causes this, but I haven't tested that.

Reproduction
Initialize a new project, and create a function that throws an error in a try block. Catch it and attempt to console.log the error. You can also try applying the google auth template, and calling googleAuthentication with a bad token (which will trip into this logic path).

Expected behavior?
The Error to be logged.

Possibly related issues:

  • #1320

Moved from:

  • #1031
bu2-confirmed arecli

All 10 comments

I also have this error message too

{ error: "Function returned invalid status code: 0. Raw body: empty.last" }

this issue has disappeared after console.log is removed.
is there any progress on this issue??

Do you have any insights into the shape of the error object?

Could you try running console.log(JSON.stringify(e)) instead?

I'm also getting this error fairly regularly. I've updated all my error handling and console logs to use e.message. There are no JSON.stringify calls anywhere in the function.

This issue is very frustrating as debugging becomes very time consuming.

I have been getting the same error. I've been using the stripe integration code from the webshop example. The very first console.log(event); is what seems to be what was causing it. Once I commented that out I started actually getting the correct errors/logs coming through.

Happening to me also. Error goes away when logging error.message instead of error.
Not sure this information helps, but in my case the error was just that I was trying to call .split() on a null value. Maybe that helps you guys figure out what the structure of the error object is.

I was having this issue due to a swolloed hard error on a synchronous function. I was using jwt.sign synchronous, after changing the code to promise based handling the error was printed out correctly

Happened to me, too. Once I got rid of all console.logs such as console.log(`Created stripe customer: ${customer.id}`) the CLI showed the errors correctly.

thanks @heymartinadams !
Found this same problem on shared cluster deployments. (Local was ok).
Solved it by adding a debug flag to all my console.logs.

@juanpprieto do you mind posting an example of what setting the debug flag on the console.logs looks like. Or do you have a link to the NodeJS documentation that shows how to use it? I was unable to find the concept in the Node docs 馃槄

Sure @grimunit
// 1. Define a debbuging flag
let debug = false;

// 2. Do a Find/Replace for "console.log" > "if (debug) console.log"
example replace: if (debug) console.log('obj', obj);

// 3. Inside export default event.. (Detect local and automatically enable console.logs on local cluster)
if (event.context.graphcool.endpoints.simple.includes(':')){ debug = true; }

p.s - There's probably better ways to do this :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

schickling picture schickling  路  3Comments

notrab picture notrab  路  3Comments

sorenbs picture sorenbs  路  3Comments

tbrannam picture tbrannam  路  3Comments

MitkoTschimev picture MitkoTschimev  路  3Comments