Current behavior
2018-01-09T07:42:50.148Z 46ms FAILURE {
"error": "Function returned invalid status code: 0. Raw body: empty.last"
}
Reproduction
const fromEvent = require('graphcool-lib').fromEvent
const er = (err) => {
console.log(err.message)
return { error: err.message }
}
const mUpdateToken = `
mutation($tokenId:ID! $balance:Float!){
updateToken(
id:$tokenId
balance:$balance
){
id
balance
}
}
`
const updateTokenBalance = async (api,tokenId,balance) => {
return (await api.request(mUpdateToken,{tokenId,balance})
.catch(er))
}
const addMinted = (a,el) =>{
if (el.transactionType==="MINT"){
return a + parseFloat(el.ammount)
}
}
const init = async function(event){
const graphcool = fromEvent(event)
const api = graphcool.api('simple/v1')
// console.log(event.data.TokenTransaction.node)
var token = event.data.TokenTransaction.node.token
console.log(token)
var minted = token.transactions.reduce(addMinted,0)
console.log('found Total Minted',minted)
balance = minted
var finished = (await updateTokenBalance(api,token.id,balance).catch(er))
console.log(finished)
return {data:{success:true}}
}
module.exports = init
subscription {
TokenTransaction(filter: {
mutation_in: [CREATED]
}) {
node{
token{
id
transactions{
transactionType
ammount
}
}
}
}
}
updateWalletBalance:
type: subscription
query: ./src/TokenTransactionCreated.graphql
handler:
code:
src: src/updateWalletBalance.js
Expected behavior?
Function should work the same remote vs deployed and return useful errors
When function is run with invoke-local:
{ id: 'cjbvq7gb459b10106sor9hvdv',
transactions:
[ { transactionType: 'MINT', ammount: 106.84382089966455 },
{ transactionType: 'MINT', ammount: 5.065958362701446 },
{ transactionType: 'MINT', ammount: 0.029171372180809393 },
{ transactionType: 'MINT', ammount: 3.132041730654067 },
{ transactionType: 'MINT', ammount: 3.9368225204850718 } ] }
console.log src/updateWalletBalance.js:68
found Total Minted 119.00781488568595
{ updateToken: { id: 'cjbvq7gb459b10106sor9hvdv', balance: 119.00781488568595 } }
Result:
{
"data": {
"success": true
}
}
Can you try replacing
const er = (err) => {
console.log(err.message)
return { error: err.message }
}
with
const er = (err) => {
return { error: "error" }
}
and see if that helps? ๐
I was getting the same error. I made the changes suggested by @marktani but now the function doesn't run at all.
Same. I moved to a different platform.
On Sat, Jan 13, 2018 at 7:42 AM, Matt Thauvette notifications@github.com
wrote:
I was getting the same error. I made the suggested changes but now the
function doesn't run at all.โ
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/graphcool/graphcool/issues/1550#issuecomment-357436291,
or mute the thread
https://github.com/notifications/unsubscribe-auth/Ac0uR1nisUnOodsvLh7MxDPGPJmuLlWvks5tKLLdgaJpZM4RXb9Q
.
--
John Heeter
Founder & CTO @ Boid.com
I have the exact same problem with a typescript function of my own.
I started from a mutation template. In its simple form it just awaited a timeout and returned some data. I added code that is working in a test program outside graphcool framework.
I know that is is partially working because I send emails and I receive them.
This is not tied to the console calls because I have none.
What can I do to help pinpoint the issue ?
Graphcool is abandoning managed functions in their latest version,
disappointing, as managed functions are part of the "Graphcool Framework"
announced in October. I ran into many issue with their implementation so I
moved to using the cli at serverless.com.
On Mon, Jan 15, 2018 at 10:17 AM, Olivier MATROT notifications@github.com
wrote:
I have the exact same problem with a typescript function of my own.
I started from a mutation template. In its simple form it just awaited a
timeout and returned some data. I added code that is working in a test
program outside graphcool framework.
I know that is is partially working because I send emails and I receive
them.
This is not tied to the console calls because I have none.
What can I do to help pinpoint the issue ?โ
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/graphcool/graphcool/issues/1550#issuecomment-357727791,
or mute the thread
https://github.com/notifications/unsubscribe-auth/Ac0uRwRNV1zAwuKXN9qwctgvaXNtnKH3ks5tK3oFgaJpZM4RXb9Q
.
--
John Heeter
Founder & CTO @ Boid.com
Hey, thanks a lot for your feedback @Boid-John, @thauvette and @omatrot ๐
I am still looking into reproducing this and finding a workaround so we can work on a fix.
@omatrot you could try to do a "binary search" on your function, to find out which specific change introduces the error message. That would be super helpful ๐
I'll do that because Graphcool is awesome. Stay tuned.
I think I've found it.
I'm using Es6 Promise
Well I'm probably wrong about my first analysis.
The function is running fine up to the point of returning data. I'm using loggly to replace console.log and it shows me that everything is fine, no exception is thrown in my code...
In a local cluster deployment it works perfectly fine.
Could you tell me how get access to the shared cluster logs ?
May be this could help.
Hey @omatrot thanks for digging into this!
Given that it works locally but not remotely makes me believe that it might be an issue in the way graphcool deploy bundles the local functions together before deploying it to AWS Lambda. My current assumption is that something causes an error when then executing the function in AWS Lambda, and that error is not correctly caught by the functions engine.
Do you see anything suspicious about the produced bundle, in the case of this error occuring?
You can enabled debug output by setting the env variable DEBUG to "*". In fish:
set -xg DEBUG "*"
@marktani I do not see something suspicious per se, but I notice that you're using ts-builder to transpile the typescript code. Does it take into account the tsconfig.json file ?
Another question : Do you use the same node.js version on the local docker engine versus the lambda engine on AWS ? I have some experience with AWS typescript lambda and node.js is version 6.10.
My playground output is the following:
{
"data": {
"addMeeting": null
},
"errors": [
{
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"addMeeting"
],
"code": 5000,
"message": "A function returned an unhandled error. Please check the logs for executionId 'us-west-2:simple:cjckp2902lyfb01804649umew'",
"requestId": "us-west-2:simple:cjckp2902lyfb01804649umew"
}
]
}
@marktani Have you the ability to check those logs ?
@marktani can you ping me on Slack ? I have material to reproduce the issue. I'd like to send you the code by email for privacy.
Thanks in advance.
Most helpful comment
I'll do that because Graphcool is awesome. Stay tuned.