Connection lost while action was in flight when using node "https"
I am using it within a "use node" actions file, but it does not work.
19 Replies
The error is: Connection lost while action was in flight
I specifically need https.get to work, I have been trying all different ways but to no avail
on further investigation, i realized that not only does https.get not work, fetch also behaves strangely compared to fetch in other node environments.
@milk enjoyer can you provide more details about how the fetch in our Node environment differs from what you're expecting?
@Michal Srb I got it to work now after troubleshooting with @lee , it turns out the problem was because the IP address of convex actions change every time because it is a new lambda instance
Having this issue now. What was the solution? How does even changing IPs cause issues doing a GET? 🤔
I use 2 API calls:
client.hostedCheckout.createHostedCheckout
works with no issues.
client.hostedCheckout.getHostedCheckout
fails without exception.
All the in-browser function execution tool says is exactly Connection lost while action was in flight
. Wrapping the API call in a try/catch
black has no effect. No output (even static, on line 1 of the action handler) is printed when that API call is called anywhere in the action.
(@james you're online :p )
I honestly have no clue how to debug this further. There's flat out zero results when googling for the error message in quotes 🤷♂️
(@milk enjoyer not sure you get notifications about this. Any more you remember? 🤔 Thanks! ❤️ )
I dug into the node_modules/
structure now. The difference between the two methods is minimal...
getHostedCheckout
:
versus createHostedCheckout
:
The action also runs for >1000ms.@jeff I’m on my phone rn so can’t debug immediately but it sounds like the errors you’re seeing are being reported client side due to a failed request. Can you post the server side error listed in the logs page of the convex dashboard? Feel free to also post your instance name and we can check error logs
Thanks, James! Appreciate the help (am totally blocked!)
Just to clarify, there isn't really a client-side involved... I an testing using the in-browser
Run Function
utilityand there's no logs in
Logs
at allhence why I am totally stuck 🙈
I put a 10 second sleep after a static console.log (and a
process.stdout.write
and a process.stderr.write
) and before the problematic API call; nop output.
So it can't be a race condition (and I think not a flushing thing either but unsure)...@jeff just to eliminate the browser aspect, could you try running this from the command line? with
npx convex run payment:verifyPayment '{"returnMAC": "INSERT HERE", "hostedCheckoutId": "INSERT HERE"}'
I'll try to repro with something similarstraight away
(N.B.: Yes I left the strings
INSERT HERE
in place because I've already hardcoded everything out of desperation XD.)Thanks, that narrows it down. What's the instance name so I can check server-side logs?
something with an animal, and an adjective to describe it... lemme look it up 😛
You can send it privately if proper security isn't set up yet
(once someone knowns this they can make calls to your application)
(except for
internal{Action/Querie/Mutation}
s right?)One thing I see (and we have an in-progress project to address this) is an error
that we should be surfacing.
Based on the code you posted the difference between these two doesn't make much sense, they both might be passing
null
to cb!
What library is this?
This particular problem was solved in DMs, this particular issue was solved by passing another argument,null
— but looks like we have an issue with crashing too hard and reporting stack traces in some situations in Node.js. We'll report when we've addressed this.The fix, on my end, in the end was to explicitly pass some
null
parameterm as I had done on the working API call also:
const createHostedCheckoutResponse = await client.hostedCheckout.createHostedCheckout(WORLDLINE_PSPID, createHostedCheckoutRequest, null);
versus
hostedCheckoutStatus = await client.hostedCheckout.getHostedCheckout(WORLDLINE_PSPID, args.hostedCheckoutId);
which now became:
hostedCheckoutStatus = await client.hostedCheckout.getHostedCheckout(WORLDLINE_PSPID, args.hostedCheckoutId, null);
Thanks for jumping in Tom. Yeah we’re actively working on surfacing error messages more clearly.
"crashing too hard" also explains why even my try/catch was fruitless :p
Yeah, thanks again Tom—really appreciate it, guys!! ❤️