Why am I Receiving "Error: Process Ended Too Soon" Despite Testing and Disabling Individual Processes?

This topic was automatically generated from Slack. You can find the original thread here.

Hiya, I’m really lost with this

Error: Process ended too soon
    at handleError (/var/task/common.js:38:40)
    at Runtime.handler (file:///var/task/lambda_handler.mjs:989:5)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

I’ve tested all the steps individually and they seem to pass individually. When i disable everything afterwards leaving just he trigger and the delay, i still get the error.

Hi Bodrul, could you share the code that’s enabled during your test? Maybe we can help provide some guidance on what we see there

Sure lemme give a quick overview, we’re just tracking order data but adding more information about the customer from other sources:
• the delay is used to wait for external apis to fully complete processing order info
• the phone number of the customer is fetched from activecampaign api using python
• the event data is then added to facebook conversions api
• and an email is sent in case of errors

To my knowledge the whole script was working fine up for a couple of months. And i have similar scripts that i haven’t touched which are continuing to work fine.

Then around a month ago, i wanted to update the script to add more customer information, but (if i remember correctly) re-deploying without any changes broke the script and i had to end up updating the python version of the script which didn’t help but i can’t revert to the oldest working version of the script

the first script uses requests and sends an email to fetch the phone number of the customer

the second python script stores the data in a dictionary and sends the data to the facebook conversions api

forgot this was public lol had to scrub the api keys

That error sounds like the workflow ended execution before the step completed, we usually see that in Node.js code steps when a promise isn’t properly fulfilled before the workflow moves onto the next step.

Is there any use of async Python code by chance?

I also highly recommend storing your API keys as environment variables: Python - Pipedream

i assume the requests might be asynchronous

Have you tried reverting to an older version of the Facebook package you’re using? There might be some kind of new change to the library that changes how requests are made

its really inconsistent. i removed all the code, then created a new step and slowly copied and pasted the code until it started passing the tests.

but then at some point, after adding a new line which didn’t seem bad at all it stopped working and removing it also prevents it from working too

testing literally the same code gives an error when previously it didn’t

lemme quickly just add the env variables

but here is the code in question:

import time, re

from facebook_business.adobjects.serverside.action_source import ActionSource
from facebook_business.adobjects.serverside.content import Content
from facebook_business.adobjects.serverside.custom_data import CustomData
from facebook_business.adobjects.serverside.delivery_category import DeliveryCategory
from facebook_business.adobjects.serverside.event import Event
from facebook_business.adobjects.serverside.event_request import EventRequest
from facebook_business.adobjects.serverside.user_data import UserData
from facebook_business.api import FacebookAdsApi

def handler(pd: "pipedream"):
    # Reference data from previous steps
    access_token = 'EA...'
    pixel_id = '...'
    test_event_code='TEST4207'

 
    #FacebookAdsApi.init(access_token=access_token)
    user_data_dict = {
        "emails": [pd.steps["trigger"]["event"]["body"]["billing_email"]]
    }

also how would i going about doing this Slack