In short, a customer was using a package that extends the Error class and renders the message property read-only.
This caused an error in FunctionLoadHandler.ts when we attempt to write our own custom error message:
error.message = `Worker was unable to load function ${metadata.name}: '${error.message}'`;
Our function ensureErrorType was not filtering out these read-only errors because instanceof Error was in fact true. Therefore, we simply returned these errors without any modification, assuming they were in fact instances of Error, not a subclass with different behavior.
This PR introduces an explicit check to ensure that we are not passing along read-only objects and hitting this exception:
Exception: Cannot set property message of [object Object] which has only a getter
This PR addresses an issue raised in the Library repo: https://github.com/Azure/azure-functions-nodejs-library/issues/205.
In short, a customer was using a package that extends the
Error
class and renders themessage
property read-only.This caused an error in
FunctionLoadHandler.ts
when we attempt to write our own custom error message:Our function
ensureErrorType
was not filtering out these read-only errors becauseinstanceof Error
was in fact true. Therefore, we simply returned these errors without any modification, assuming they were in fact instances ofError
, not a subclass with different behavior.This PR introduces an explicit check to ensure that we are not passing along read-only objects and hitting this exception: