Help

Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

Scripting block having error with serverless function

Topic Labels: Custom Extensions
Solved
Jump to Solution
1511 5
cancel
Showing results for 
Search instead for 
Did you mean: 

Hi everyone!

I have a table, a collection of URLs to different articles and videos. I wanted to have the text parsed from these URLs (the content of the article, description of a youtube video). I made it with python (beautifulsoup4) and made a serverless function for this. When I’m running it in scripting block, it gives an error message (‘TypeError: Failed to fetch at Failed to fetch’). It appears sometimes after passing perfectly 10 URLs and sometimes after 38, or after 3. So it looks completely random. When it runs to an error, I test it with the serverless function outside of Airtable’s scripting block, and it works fine there.

Do you know anything, what could cause the error in random lines?

Thank you in advance for the help!

1 Solution

Accepted Solutions

The intermittent Failed to fetch error suggests that sometimes your serverless function is failing to return a valid response.

When this happens, you can debug it by looking at the Network panel of the browser’s developer tools.

See Solution in Thread

5 Replies 5

Can you paste the code for your script here? I wonder if some of the URLs cause the serverless function to throw an error, which would then make the fetch fail as well.

Sure, here is the script code:

const table = base.getTable(“Content”);
const query = await table.selectRecordsAsync()
for (let record of query.records) {
const articleUrl = record.getCellValueAsString(“URL”);
const response = await fetch( https://mtgzblpjf0.execute-api.us-east-1.amazonaws.com/dev/hello?url=${articleUrl} );
const data = await response.json();
console.log(‘articleUrl’, articleUrl);
table.updateRecordAsync(record, {
“Article’s Title”: data.title,
“Article’s Content”: data.text,
});
}

I’m checking if it works with the console.log function.

In the examples, fetch uses the config option cors: true,, so maybe try that. There’s also some config on Amazon to enable CORS.

The intermittent Failed to fetch error suggests that sometimes your serverless function is failing to return a valid response.

When this happens, you can debug it by looking at the Network panel of the browser’s developer tools.

Thanks! I modified the serverless function a bit and it runs well now. It just have a problem with the youtube links, but that is a different topic :slightly_smiling_face: