Functions logs not loading

Hello, we are having trouble accessing the functions logs in the Netlify UI. All we see is the “slash” thing spinning but no actual output. The function has been invoked today by a webhook and returned 200 so we are sure something must have been logged. We have this problem also on the staging version of the site, from which we’ve read the logs correctly in the past days, but not anymore.

Hi Matteo,

Function logs last only 1 hour after invocation. I suspect your last invocation was more than an hour ago. If you execute the function anew, do you see logs? If not, please let us know the value of the x-nf-request-id http response header, which you can get as described in this article:

I’m having the same problem (no logs for functions, just has the spinning slash, and it has been less than an hour). I’m not sure which request I should be looking at for the x-nf-request-id, so I just took it from the request for the page.

x-nf-request-id: 7c99a059-061e-4fa9-a7b2-9770a8a54b19-101635051

I’m trying to get a deploy-building function to work.

If it helps, the site I’m working on has two functions right now: deploy-building.js and submission-created.js. The logs for submission-created do work but deploy-building does not. My expectation is that when I initiate a deployment, or an automatic deployment is triggered, deploy-building should run, but I’m not sure if this is happening.

Edit: It turned out that my asynchronous things weren’t getting a chance to run before the function “completed.” I successfully got the function to wait for the asynchronous things to finish before returning a 200, and now I have logs and new problems. :slight_smile:

1 Like

I’m surprised that you see logs for submission-created.js - as far as I know we don’t currently intend to display logs for any event-triggered function (these in particular: https://docs.netlify.com/functions/trigger-on-events/#available-triggers). Form submissions might be special since the form submission is in essence “sent” to the function, but that is unfortunately working as designed. I have an open feature request to show those logs and have attached this thread to it, so we can report back if the situation changes.

I’ve also marked this thread for discussion with the documentation team to see if we can make it clearer that this is the case, since it has been the case for well over a year now.

Very sorry that you spent time debugging it!

1 Like

Hey folks, long time no see! We think we have a fix live now so that event-triggered functions now show logs as expected. Please let us know if you aren’t seeing that and hopefully provide us some reproduction steps so we can reopen the bug report based on that if needed.

I’m still not seeing logs or sucessful execution from my submission-created.js (which sends an email)
It executes fine locally, and when I copied it over to another name and deployed it I got logs come through and the email arrived after a GET to the endpoint.

Could you let me know what site you’re talking about, @simont , and the URL to the form, so I can reproduce, help troubleshoot, and potentially reopen the bug?

1 Like

2 posts were split to a new topic: Function logs not loading anymore

Hey @simont,
I just confirmed that I was able to get logs from a submission-created function.

// submission-created.js
exports.handler = async function(event, context) {
    console.log(JSON.parse(event.body))
    return {
      statusCode: 200
    };
};
// log
2:26:20 PM: 2020-09-01T21:26:20.581Z	15c29b19-722f-4d3d-85d4-00f3325fe2cf	INFO	{
  payload: {
    number: 42,
    ...
    summary: 'Atlantic City Fog',
    body: null,
    data: {
      tea: 'Atlantic City Fog',
      ip: '...',
      user_agent: '...',
      referrer: 'https://competent-curran-1788d6.netlify.app/'
    },
    created_at: '2020-09-01T21:26:19.833Z',
    human_fields: { Tea: 'Atlantic City Fog' },
    ...

That leads me to suspect that there’s some other reason why the function is not triggering for you. Could you try removing password protection and seeing if you receive the email/see logs that way?

1 Like

Thanks @jen. You are correct. I took password protection off momentarily, submitted the form and the function triggered with only a short delay. This solves the immediate problem as I suppose I can develop and test the function locally and test the deployed version in the same way.

It would be useful long-term to test deployed functions behind password protection as we may make use of this feature for a staging site

Hey @simont,
Totally agree, that use case makes lots of sense. Before I file a feature request, I have one more followup question! What browser were you using to test? I ask because Safari is on our radar for a related issue: after entering the password, it does not forward the auth header when requesting site assets, so they 404. Not sure this is related, but it would be helpful to have that additional detail. Thank you!

1 Like

I was using firefox. Good to hear

Thanks! Filed that feature request and will update here if/when there’s movement on it.

Just checking back to see if there has been any movement on supporting submission-created working behind a password-protected site?

looks like we are still discussing this, but at the moment I have nothing new to share, unfortunately. I will definitely circle back here if there is any movement.