GoogleCloudPlatform / functions-framework-nodejs

FaaS (Function as a service) framework for writing portable Node.js functions
Apache License 2.0
1.29k stars 160 forks source link

fix: module resolution returns early and accurate error messages on failure #534

Closed garethgeorge closed 1 year ago

garethgeorge commented 1 year ago

The existing module resolution logic has two logic errors which create a confusing experience when the customer's module isn't found:

  1. null is never returned even when the module is not found, this means function framework doesn't early return with an exception when it should if the function does not exist.
  2. The error message will accurately reflect the original path instead of including /function.js prefix which gets incorporated as a side effect of the implementation today.

This change simplifies the function and cleans up these errors.