Thanks for still thinking about it.
Thanks for still thinking about it. Unfortunately, that doesn't work or not at least locally.
It does not return anything as the fetch never completes, so the function just shows 500 internal error on the server but doesn't execute any further. I tried shortcircuit with datares.status to check for 500 but it doesn't work that way as by that time the function errors out and not the origin server (for which datares checks for).
The 500 error is the function error but nothing is checking for the function error itself. I am not sure if I am explaining it well. I found out this, apparently the 500 error will only be returned if its timeout by due to DNS error https://community.cloudflare.com/t/community-tip-fixing-error-500-internal-server-error/44453 but other reasons it will not return anything like in my case where the origin server does not respond. The linked docs page in that article seems helpful for all the possible CF error codes
It does not return anything as the fetch never completes, so the function just shows 500 internal error on the server but doesn't execute any further. I tried shortcircuit with datares.status to check for 500 but it doesn't work that way as by that time the function errors out and not the origin server (for which datares checks for).
The 500 error is the function error but nothing is checking for the function error itself. I am not sure if I am explaining it well. I found out this, apparently the 500 error will only be returned if its timeout by due to DNS error https://community.cloudflare.com/t/community-tip-fixing-error-500-internal-server-error/44453 but other reasons it will not return anything like in my case where the origin server does not respond. The linked docs page in that article seems helpful for all the possible CF error codes
2 Replies
@IEatBeans Sorry to tag you but I wanted to notify you of this thread I am creating.
I cannot share the code snippet as such as I am not sure I know how to share a code snippet that would make sense 😛 But herees a psuedo code explaining that problem.
Now the problem with 500 internal error is that if hello.js can't fetch from the originurl (only when the originurl is down or inaccessible), it doesn't throw that error to be caught in the catch block for me. It just returns 500 internet error on the server side instead as the try catch block is only to look for fetch errors from the originurl. But the way functions works, it seems if originurl doesn't respond, the function errors out completely, like it terminates itself. So I can't handle inside the function. The only way to do that is to handle the possible function error on the frontend.
What is the actual error message that your function is returning with the 500
If you tail the function and repro the error you should be able to see that