Github action cronjob curl POST doesn't always work

Viewed 1138

I've setup a github action on a private repository, free account, as a cron so that runs every day at 9am:

name: updates
on:
  schedule:
    - cron: '0 9 * * *'
jobs:
  cron:
    runs-on: ubuntu-latest
    steps:
      - name: Call our API route
        run: |
          curl --request POST \
          --url 'https://mysite.vercel.app/api/myjsfile' \
          --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}'

but I've noticed that while if I open https://mysite.vercel.app/api/myjsfile manually in browser it works as expected, saving all the data in my mongodb (inside myjsfile.js it goes through a for loop and save each in a collection), when it gets called via cron either it doesn't work or it goes through 1-2 loops at max.

What am I doing wrong here? I've checked for github action timeouts but it seems the cron timeouts after hours, so it shouldn't be the issue here since the whole process when I open the api url manually it takes about 3-4 minutes

EDIT 1: modified to GET request as suggested, but without any changes

EDIT 2: thanks to the logging suggested below, which returns:

2021-01-27T09:20:35.6297813Z ##[group]Run curl --request GET \
2021-01-27T09:20:35.6298606Z [36;1mcurl --request GET \[0m
2021-01-27T09:20:35.6299479Z [36;1m--url 'https://xxxxxxxxx.vercel.app/api/myjsfile' \[0m
2021-01-27T09:20:35.6301000Z [36;1m--header 'Authorization: ***'[0m
2021-01-27T09:20:35.7007371Z shell: /bin/bash -e {0}
2021-01-27T09:20:35.7008125Z ##[endgroup]
2021-01-27T09:20:37.5226619Z   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
2021-01-27T09:20:37.5227783Z                                  Dload  Upload   Total   Spent    Left  Speed
2021-01-27T09:20:37.5228270Z 
2021-01-27T09:20:37.5229486Z   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
2021-01-27T09:20:38.0606613Z   0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
2021-01-27T09:20:39.5213317Z   0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0
2021-01-27T09:20:40.0623420Z   0     0    0     0    0     0      0      0 --:--:--  0:00:03 --:--:--     0
2021-01-27T09:20:41.0637824Z   0     0    0     0    0     0      0      0 --:--:--  0:00:04 --:--:--     0
2021-01-27T09:20:42.0648174Z   0     0    0     0    0     0      0      0 --:--:--  0:00:05 --:--:--     0
2021-01-27T09:20:43.0660811Z   0     0    0     0    0     0      0      0 --:--:--  0:00:06 --:--:--     0
2021-01-27T09:20:44.0672977Z   0     0    0     0    0     0      0      0 --:--:--  0:00:07 --:--:--     0
2021-01-27T09:20:45.0686998Z   0     0    0     0    0     0      0      0 --:--:--  0:00:08 --:--:--     0
2021-01-27T09:20:46.0697253Z   0     0    0     0    0     0      0      0 --:--:--  0:00:09 --:--:--     0
2021-01-27T09:20:47.0708765Z   0     0    0     0    0     0      0      0 --:--:--  0:00:10 --:--:--     0
2021-01-27T09:20:48.0063092Z   0     0    0     0    0     0      0      0 --:--:--  0:00:11 --:--:--     0
2021-01-27T09:20:48.0071894Z 100    68  100    68    0     0      5      0  0:00:13  0:00:12  0:00:01    13
2021-01-27T09:20:48.0073622Z 100    68  100    68    0     0      5      0  0:00:13  0:00:12  0:00:01    17
2021-01-27T09:20:48.0089257Z An error occurred with this application.
2021-01-27T09:20:48.0089948Z 
2021-01-27T09:20:48.0090483Z NO_RESPONSE_FROM_FUNCTION

I've seen that there's a NO_RESPONSE_FROM_FUNCTION error at the end, and it may have to do with the fact that the plan on vercel is a "hobby" one for now, so it may be the max timeout of 10s for serverless functions as shown in the screenshot below?

vercel general limits

It's weird though cause when I go to the /api/myjsfile manually as said it works fine, is it because isn't seen as "serverless" by vercell contrary to when it's executed via cronjob?

0 Answers
Related