While experimenting with which identity functions get triggered when for both identity and exteral In got several weird errors. I’m using CI via GitHub and a PR preview deploy
Say I delete identity-validate and push to deploy then the Netlify Identity Widget throws an error about being unable to call somehting. I found the problem goes away if use the panel to delete the cache and redeploy. So it seems deleted functions are half deleted and half cached in some strange way.
Oh, also the docs say that the identity-login function is not called when using external providers (eg google) but in fact none of the login/logout or verify are.
There’s a few things to unpack here. I’ll answer the last thing first, since it’s the easiest to explain. Logging for event-triggered functions are not currently working. Only logging for non-event-triggered functions will show logs.
For the error with the Identity Widget, when do you see the error? Can you provide reproduction steps on how you get the error?
For the error with the Identity Widget, when do you see the error? Can you provide reproduction steps on how you get the error?
I’ll have a go. but what I had awas
add a identity-validate function that just logs. Or I think others like identity-login. Push and test by loggin in. Logout. Delete the function. Push and test by logging in. The error occurs in the identity widget
I was getting apparently non-deterministic bahaviour which was very confusing. Till I tried to “delete cash and redeploy”
Ah, so indeed it does. Thanks for confirming that your logs do work.
With your reproduction steps, do you refresh your site before logging in again? If you have you site currently loaded in the browser, it won’t automatically update itself without some client-side trigger to do so (e.g. hitting the refresh button). Since this is the case, the widget that is currently loaded won’t be aware of the latest changes and could be the reason you are seeing the error.
Hey @Dennis just adding here - the last few days I’ve been building an Identity/Functions demo project and I can confirm as well, the logging for events-based Functions (at least identity-signup) has been working fine for me too!
Hmm, I don;t think the client side refresh is relevent and don’t think I refresh it, only redeployed and deleted cache. However it is hard to know the client did not refresh.
What I see is if I delete an auth triggered function it is still invoked but errors as not existing - all in the back end as the error occurs in the back end. But perhaps you are right and it requires the front end to not call it, rather than the front end always calls it anyway an it gets ignored if it does not exist - except it doesnt :).
When you delete a function, our system removes it. There is no way for our system to force your site to reload and it’s outside the scope of our system, so you will need to handle that yourself.
Regarding the Google auth, when you log in using that, it won’t trigger the function since that method doesn’t involve your site’s Identity instance, so that makes sense that nothing gets called.
Again, if you delete a function, you need to refresh/reload your site. I don’t think there’s getting around.
When you say “site” - do you mean front end or back end, or both.
In this case its a function called by the official Auth widget and it I can supply it or not. I would expect the widget or it’s associated backend look for my function before calling it. It’s all transparent to me as it’s encapsulated in the netlify auth login and I either supply the function or not.
I add the function and deploy the function is called. If I then delete it a strange error occurs and I sould expect it to just not error,
I refer to the client-side, so Frontend. That said, event-triggered functions aren’t meant to be added/removed on the fly. It’s not the intent. When you add a function and deploy, you reload your browser for the function to get triggered. The same goes for removing the function. The behavior you are seeing is normal.