vercel / fun

ƒun - Local serverless function λ development runtime
Apache License 2.0
482 stars 26 forks source link

fix: Ref custom error classes instead of new.target #80

Closed cb1kenobi closed 1 year ago

cb1kenobi commented 1 year ago

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.

For example, the original code looked like this:

Object.setPrototypeOf(this, new.target.prototype);

But ncc would output:

Object.setPrototypeOf(this, /* unsupported import.meta.prototype */ undefined);

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.

This should partially fix https://github.com/vercel/vercel/issues/8000.

github-actions[bot] commented 1 year ago

:tada: This PR is included in version 1.1.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: