While there's nothing wrong with using new.target, it turns out that ncc has been stripping them for some reason. Subsequently, if an error occurred while invoking a lambda function, the actual error would never be displayed since the LambdaError creation would fail with an error Object.setPrototypeOf() with an object or null.
I couldn't find any instances where we derive errors from LambdaError or ValidationError, so it shouldn't be a problem to replace new.target with the class name.
While there's nothing wrong with using
new.target
, it turns out thatncc
has been stripping them for some reason. Subsequently, if an error occurred while invoking a lambda function, the actual error would never be displayed since theLambdaError
creation would fail with an errorObject.setPrototypeOf()
with an object ornull
.For example, the original code looked like this:
But
ncc
would output:I couldn't find any instances where we derive errors from
LambdaError
orValidationError
, so it shouldn't be a problem to replacenew.target
with the class name.This should partially fix https://github.com/vercel/vercel/issues/8000.