Code errors result in CORS errors

Run into an interesting issue today, thought it might be worth detailing here. I recently had been working in a project that was using Babel and allowed me to take advantage modern JS features so I was in a habit of writing code which is not yet supported. Anyway, I noticed after I recently made some changes to a Lambda that I was getting a CORS issue come up on a client. I was rather confused, so I checked the endpoint and saw I had a Runtime.UserCodeSyntaxError error and quickly found out what was causing the error, fixed and re-deployed (it was a conditional prop?.name that was the problem).

What really caught my attention was that CORS issue response I received on the client despite the code in question having correctly setup error handling. The client accessing the Lambda was cross domain and that seemed to be why it returned a CORS issue because when accessing the endpoint directly error handling sufficed.

The syntax issue caused the lambda to fail when executing and though the origin handled the error correctly the client which is cross-origin (another domain) received a CORS cross-origin error as a response, essentially it failed to return the error callback.

What might cause this to occur? Could it be that the because I pass the error to the 1st parameter of a callback function, eg:

try { 
} catch(error) {
   callback(error, , {
       statusCode: 500,
       headers: {
           'Access-Control-Allow-Origin': '*',
           'Content-Type': 'application/json'

I am curious as if this is intended functionality from Netlify? Any thoughts would be great. Thanks